Lol, yeah it would be shorter and more effiecient, it just didnt occur to me not to use an array.
It depends if you want access to each individual number afterwards or not I guess.
If you just want the highest number in the list, then use this code:
Code:
#include <iostream>
#include <fstream.h>
#include <ctype.h>
using namespace std;
int Highest();
int Highest()
{
char filename[80]; //The file you want to open
int HighestValue = 0; //This will store the largest value from the text file
int tempint = 0; //This will store the converted temp variable
string temp; //Where we store the string we ouput from the file
cout << "File: "; //Ask for a filename
cin >> filename;
ifstream fin(filename); // Open the file passed to this function for reading
cout << "Processing File...."<<endl;
while (getline(fin,temp))
{
tempint = atoi(temp.c_str());
if (tempint>=HighestValue)
{
HighestValue=tempint;
}
}
fin.close(); //Close the file again
cout << "Done...."<<endl;
return(HighestValue);
}
Use it in the same way as I described before.
Chris