I have written code at the bottom to write 100 random numbers to a file then read the file but Im not sure how to get it to read all 100 numbers, also I need to have it pick out the greatest number which I have no clue as to how to do
CODE:
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
int main()
{
int num[120];
int counter;
char str[10];
ofstream outstream("digits2.dat");
if(outstream.fail())
{
cout<<"File Problem"<<endl;
exit(1);
}
int x;
srand(time(NULL));
for(counter=0; counter<100; counter++)
{
x=1 + rand() % 100;
}
outstream<<x;
outstream.close();
ifstream instream("digits2.dat");
instream>>x;
cout<<x<<endl;
instream.close();
return(0);
}
ThANX for any Help