Disk file I/O with Streams

PHOTO EMBED

Mon Apr 26 2021 23:51:09 GMT+0000 (Coordinated Universal Time)

Saved by @ahmedqgqgq #java

/*the fstream library allows us to work with files.
To use The fstream library,include both the standard:
<iostream>AND the <fstream> header file:
Example:
#include<iostream>
#include<fstream>
there are three classes included in the fstream Library.
Which are used to Create,Write or read file:
ofstream:Create and Writes to files.
ifstream:Reads from files.
fstream:A Combination of ofstream and ifstream:creates,reads,and writeto files.*/
/*******************************************************************************/
//Create and Write To File.
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
	//Create and open a text file.
	ofstream Myahmedfile("ahmedfile.txt");
	//Write to the file.
	Myahmedfile << "Hello Ahmed Abdelmoneim";
	//Close the file.
	Myahmedfile.close();
}
content_copyCOPY