Weve been given this example to work with and Im not sure about the line 9 char cont = 'n'; - is there even a need for it? The rest of the program I understand.
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int no = 1;
FILE *nofile = NULL;
char cont = 'n';
// read numbers from file
if ( (nofile = fopen( "numbers.dat", "rb" )) == NULL )
{
cout << "Cannot open numbers file" << endl;
exit( -1 );
}
cout << endl;
cout << "Stored numbers are" << endl;
fread( &no, sizeof( no ), 1, nofile );
while ( feof( nofile ) == 0 )
{
cout << no << endl;
fread( &no, sizeof( no ), 1, nofile );
}
fclose( nofile );
cin.ignore();
cin.get();
}