Answers for "fstream function in cpp"

C++
3

fstream in c++

#include<fstream>
int main()
{
  fstream file; 
  /*if we use fstream then we need to specify at least one 
  parameter mode like ios::out or ios::in else the file will not open */  
  file.open("filename.txt", ios::out|ios::in);
  /*all work with file*/
  file.close();
  return 0;
}
Posted by: Guest on March-26-2021
0

write to file in C++

ofstream myfile;
myfile.open("file.txt");

myfile << "write this to file"
Posted by: Guest on July-01-2020

Browse Popular Code Answers by Language