User Tools

Site Tools


c_-_c_files:sequentially_write_to_a_file

C - C++ Files - Sequentially write to a file

#include <iostream>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::ios;
 
#include <fstream>
using std::ofstream;
 
#include <cstdlib> 
using std::exit;
 
int main()
{
  ofstream outClientFile( "clients.dat", ios::out );
 
  if ( !outClientFile )
  {
    cerr << "File could not be opened" << endl;
    exit( 1 );
  }
 
  int account = 12;
  char name[80] = "This Is A Test"; 
  double balance = 123.123;
 
  outClientFile << account << ' ' << name << ' ' << balance << endl;
 
  return 0;
}
c_-_c_files/sequentially_write_to_a_file.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki