Match the LIST-I with LIST-II
| |
LIST-I (file mode parameters) |
|
LIST-II (Meaning) |
| A. |
ios::ate |
I. |
Go to end of file on opening |
| B. |
ios::in |
II. |
Open fails if the file already exists. |
| C. |
ios::nocreate |
III. |
Open file for reading only |
| D. |
ios::noreplace |
IV. |
Open fails if the file does not exist. |
Choose the correct answer from the options given below:
1.A-III, B-IV, C-II, D-I
2.A-I, B-III, C-II, D-IV
3.A-II, B-IV, C-I, D-III
4.A-I, B-III, C-IV, D-II ✓ Correct
Solution
The correct answer is A-I, B-III, C-IV, D-II.
Key Points
- A. ios::ate → I
- Opens file and moves the file pointer to the end of file immediately.
- B. ios::in → III
- Opens file in read-only mode.
- C. ios::nocreate → IV
- Opening fails if the file does not exist.
- D. ios::noreplace → II
- Opening fails if the file already exists.
Additional Information
- C++ File Modes Summary:
- ios::in → read mode.
- ios::out → write mode.
- ios::ate → pointer at end.
- ios::nocreate → fail if file missing.
- ios::noreplace → fail if file exists.