tags:

views:

92

answers:

1

How to append text to a text file in C++? Create new if does not exist and append if exist.

+8  A: 
#include <iostream>
#include <fstream>

int main(void) {  
  std::ofstream outfile;

  outfile.open("test.txt", std::ios_base::app);
  outfile << "Data"; 
  outfile.close();
  return 0;
}
Bertrand Marron
Thanks brother :)
Ahmad Farid