// justin C. Miller
// 3-29-2001
// made for : http://www.geocities.com/neonprimetime.geo/index.html
// made in: Borland C++ Builder 4.0
// Title: File Input/Output
// Description: create data file, store 5 names
// read names from data file, output them to screen
#include
#include
#include
int main(){
ofstream outfile ; // outfile is my output object (just like cout)
outfile.open("data.dat") ; // opening my data file (creating new
// one if data.dat doesn't exist
char * names[5] = {"Rock", "StoneCold", "Austin", "UnderTaker", "Jericho"} ;
for(int i = 0 ; i < 5 ; i++)
outfile << names[i] << endl ; // just like cout <<
// i'm sending these names to the data file
outfile.close() ; // close my data file for output
ifstream infile ; // infile is my input object (just like cin)
infile.open("data.dat") ; //opens the data file data.dat for
// input purposes, it is the same file
// we just outputted to
char * name = new char[25] ;
cout << "Names..." << endl ;
cout << "--------" << endl ;
for(int j = 1 ; j <= 5 ; j++){
infile >> name ;
cout << j << ".) " << name << endl ;
} // the data file is outputed in a nice formate
infile.close() ; // close my data file for input
getch() ; // pauses the screen for reading purposes
return 0 ;
}
// OUTPUT LOOKS LIKE...
// Names....
// ---------
// 1.) Rock
// 2.) StoneCold
// 3.) Austin
// 4.) UnderTaker
// 5.) Jericho
               (
geocities.com/neonprimetime.geo/cpp)                   (
geocities.com/neonprimetime.geo)