Question

In: Computer Science

Code in C++ programming language description about read and write data to memory example.

Code in C++ programming language description about read and write data to memory example.

Solutions

Expert Solution

#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;

}


Related Solutions

Code in C++ programming language description about lesson Calculator (multiple, sum, dived, sub) example.
Code in C++ programming language description about lesson Calculator (multiple, sum, dived,  sub) example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Code in C-language programming description about convert binary number to decimal number.
Code in C-language programming description about convert binary number to decimal number.
Class object in C++ programming language description about lesson Overloading function example.
Class object in C++ programming language description about lesson Overloading function example.
Class object in C++ programming language description about lesson copy constructor example.
Class object in C++ programming language description about lesson copy constructor example.
Class object in C++ programming language description about lesson static variable example.
Class object in C++ programming language description about lesson static variable example.
Class object in C++ programming language description about lesson inheritance multi level example.
Class object in C++ programming language description about lesson inheritance multi level example.
Class object in C++ programming language description about lesson unary overloading function example.
Class object in C++ programming language description about lesson unary overloading function example.
Class object in C++ programming language description about lesson base class and derived class example.
Class object in C++ programming language description about lesson base class and derived class example.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT