//Read from the file.
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
//Create a text file.
ofstream Mywritefile("fileAhmed.txt");
//Write to the file.
Mywritefile << "Ahmed abdelmoneim!\nmohamed";
//Close the file.
Mywritefile.close();
//Create a text string,
string myText;
//read from the text
ifstream Myreadfile("fileAhmed.txt");
while (getline(Myreadfile, myText))
{
cout << myText;
}
Myreadfile.close();
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter