Need a project done?

C++ Programming Developer

Search This Blog

Write in a file C++


#include <iostream>
#include <fstream>//Used for file handling.

using namespace std;

int main(){
ofstream outfile;
outfile.open("rehan.txt");//This file will be created in the directory in which you've created your project.

outfile << "My name is Rehan\nand I love to play football" << endl;
cout << "File Written" << endl;

return 0;
}
See also:

Read from a file C++

"Don't let anyone ever make you feel like you don't deserve what you want."