|
|
|
© 1998 by Bobby Griggs.
// Program name: Read from file
// Purpose: To read five names from a text file.
// Win32 console application
#pragma hdrstop
#include < iostream.h >
#include < stdio.h >
#include < fstream.h >
#include < assert.h >
#include < conio.h >
void Names_from_file();
#define FILENAME "names.dat"
void main()
{
Names_from_file();
return;
}
void Names_from_file()
{
char name[30];
ifstream name_file;
int i;
name_file.open(FILENAME);
assert(!name_file.fail());
while (!name_file.eof())
{
name_file.getline(name,sizeof(name));
cout << name << endl;
}
name_file.close();
assert(!name_file.fail());
cout << endl;
cout << "Press any key to continue ... " << endl;
getche();
return;
}
|