Files
In Africa.txt I have saved
1 Sun 23 45 66 44.6667
2 Cona 45 66 77 62.6667
3 Jimy 45 77 88 70
And also I want this as my output.But this program outputs
"0 Sun 23 45 66 44" line infinitely..
Can anyone help me for fix this error?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;
int main()
{
int n, s1,s2,s3,cal ;
string name;
ifstream get("Apple3.txt");
while(!get.eof())
{
get>>n>>name>>s1>>s2>>s3>>cal;
cout<<n<<" "<<name<<" "<<s1<<" "<<s2<<" "<<s3<<" "<<cal<<endl;
}
return 0;
}
|
Last edited on
44.6667 is not an int so trying to read it into int value leads to stream set into failed state and nothing is read again
Topic archived. No new replies allowed.