Prepare
Practice
Interview
Aptitude
Reasoning
English
GD
Placement papers
HR
Current affairs
Engineering
MCA
MBA
Online test
Login
Not possible combine two or more file opening mode in open () method - File Handling
Home
>>
Category
>>
C++ (MCQ) questions and answers
>>
File Handling
Q. It is not possible to combine two or more file opening mode in open () method.
- Published on 19 Oct 15
a.
True
b.
False
ANSWER: False
Related Content
Constructor and Destructor (
10
)
Operator Overloading (
11
)
Inheritance (
16
)
Polymorphism and Abstract Classes (
12
)
C++ basic concepts (
39
)
Exception Handling (
22
)
File Handling (
11
)
Functions (
20
)
Memory Management (
6
)
Pointers (
3
)
Discussion
Nihal
-Posted on 06 Oct 15
You can combine two or more file opening mode in open () method.
A file must be opened before you can read data from it or write to it. You can use either ofstream or fstream object to open a file for writing and ifstream object for reading.
Following is the syntax for open() function.
void open(const char * filename, ios::openmode mode);
some of the important mode are as follows.
ios::app Append mode.
ios::in Open a file for reading.
ios::out Open a file for writing.
ios::trunc If the file already exists, data will be truncated.
You can combine two or more of these values.
ofstream fileObj;
fileObj.open("filename.txt", ios::out | ios::trunc );
➨
Post your comment / Share knowledge
Required!
Required!
Invalid Email Id!
Required!
Enter the code shown above:
Please enter the code shown above
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)
MCQs
English
Tutorials
Download
▲