Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

file c++

#include <iostream>
#include <string>
#include <fstream> //write and read
//#include <ifstream> //read
//#include <ofstream> //write

int main () {
  std::string line;
  std::ofstream myfileWrite;
  std::ifstream myfileRead;
  myfileWrite.open("example.txt");
  myfileRead.open("example.txt");
  myfileWrite << "Writing this to a file.
";
  while (getline(myfileRead,line)){
    std::cout << line << '
';
  }
  myfileWrite.close();
  myfileRead.close();
  return 0;
}
 
PREVIOUS NEXT
Tagged: #file
ADD COMMENT
Topic
Name
6+1 =