In: Computer Science
Code in C++ programming language description about read and write data to memory example.
#include
#include
#include
using namespace std;
int main(){
char name[50];
int age;
fstream outfile;//Open file to write continuse
outfile.open("EXAMPLE.txt",ios::in);//how to open file
cout<<"Writing to file "<
cout<<"Enter your name ";cin.getline(name,50);
cin.clear();//use cin.get for file can cath all data that user has wrote
outfile<
cout<<"Enter your age :";cin>>age;
outfile<
outfile.close();//close file
fstream infile;//open file to read data folow name
cout<<"\nReading from the file:"<
infile>>name[50];//show data file for name
cout<<"Name: "<
infile>>age;//show data file for age
cout<<"Age: "<
infile.close();//close file that has opened
return 0;
}