source file:
1,2
2,5
3,7
4,9
5,11
output:Code:int readin(_tag_xandy data[100], ifstream & fin, int & n)// read data from file function { char tmpchar; while (!fin.eof()) { fin>>data[n].x>>tmpchar>>data[n].y; cout<<data[n].x<<','<<data[n].y<<endl; ++n; //cout << "what is n??"<<n<<endl; //for dubugging } //if(data[n].x==NULL||data[n].y==NULL) //return n-1; //else return n ; //cout<<"after n=n-1...~~n="<<n<<endl; }
1,3
2,5
3,7
4,9
5,11
0,0
This function is to read from a text file, the output is generated of the struct of arrays in another function.
As you can see, the source file dont contain that group of number 0,0
which appear in the output.
Rest of the codes are okay, I think something cause the difference.
Could u help me out?How to change the codes???Thanks.
The red part may the causes. The cursor in the source file is not just at the end of the file.



LinkBack URL
About LinkBacks



