Reading and writing of files in C++<\/span><\/p>\n A file must be opened before you can read from it or write to it. Either the\u00a0ofstream<\/strong>\u00a0or\u00a0fstream<\/strong>object may be used to open a file for writing and ifstream object is used to open a file for reading purpose only.<\/p>\n Following is the standard syntax for open() function, which is a member of fstream, ifstream, and ofstream objects.<\/p>\n Here, the first argument specifies the name and location of the file to be opened and the second argument of the\u00a0open()<\/strong>\u00a0member function defines the mode in which the file should be opened.<\/p>\nOpening a File:<\/h2>\n
#d6d6d6;\">void<\/span> open<\/span>(<\/span>const<\/span> char<\/span> *<\/span>filename<\/span>,<\/span> ios<\/span>::<\/span>openmode mode<\/span>);<\/span><\/pre>\n