i have a code that reads lowest and the highest number with inputs that are all Integer
but, once i have an input (ex. apple 200)...it wont read anymore, need help in what to input code that ignores letters
//reads numbers only ex. 100 200 300
int main()
{
ifstream in;
ofstream out;
in.open("input.txt");
if (in.fail())
{
cout<<"Unable to open \"Input.txt\"";
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cin.get();
exit(1);
}
int number, lowest=numeric_limits<int>::max(),highest =0;
in>>number;
while(!in.eof())
{
if(number >highest)
{
highest=number;
}
if(number<lowest)
{
lowest =number;
}
in>>number;
}
out<<"Highest is: "<<highest<<endl;
out<<"Lowest is : "<<lowest<<endl;
in.close();
out.close();
cout<<"Done";
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cin.get();
return 0;
}