A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_fstream_open.htm below:

C++ fstream Open

C++ Fstream Library - Open Function Description

Opens the file identified by argument filename, associating it with the stream object, so that input/output operations are performed on its content. Argument mode specifies the opening mode.

Declaration

Following is the declaration for fstream::open.

C++98
void open (const char* filename,ios_base::openmode mode = ios_base::in | ios_base::out);
C++11
void open (const char* filename,ios_base::openmode mode = ios_base::in | ios_base::out);
void open (const string& filename,ios_base::openmode mode = ios_base::in | ios_base::out);
Parameters Return Value Exceptions Data races Example

In below example explains about fstream open function.

#include <fstream>

int main () {

   std::fstream fs;
   fs.open ("test.txt", std::fstream::in | std::fstream::out | std::fstream::app);

   fs << " more lorem ipsum";

   fs.close();

   return 0;
}

fstream.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4