To read or write to a file, you include : fstream « File « C++






To read or write to a file, you include

  
#include <fstream>
int main()
{
  using namespace std;

  int intValue;
  float realValue;
  ifstream inData;
  ofstream outData;

  inData.open("input.dat");
  outData.open("output.dat");

  inData  >> intValue;
  inData  >> realValue;
  outData << "The input values are "
          << intValue  << " and "
          << realValue   << endl;
  return 0 ;
}
  
    
  








Related examples in the same category

1.fstream seekp: Seek file pointer position
2.Reverse file content
3.Demonstrate File random access.
4.Reverses the first N characters within a file
5.File Stream Objects as Function Arguments