kunny funt
Large Member
- Joined
- Oct 29, 2004
- Messages
- 153
- Gender
- Male
- HSC
- 2004
ok this is the weirdest problem. I am using a getline function to count the number of students in a certain file:
int n;
while(!inFile.eof())
{
getline(inFile, myString);
n++;
}
which is simple enough right, ill get a value for n which i can use throughout the whole program, well apparently not.
HOwever, if instead of using this function, i just set the value of n to be the number(which i know for this certain file) like instead of the thing above, i just write:
int n=40;
then the program works
W T F......... srsly, its like exactly the same thing yet only one way works and i cant use that way for all input files.
can anyone tell me why????????????????
int n;
while(!inFile.eof())
{
getline(inFile, myString);
n++;
}
which is simple enough right, ill get a value for n which i can use throughout the whole program, well apparently not.
HOwever, if instead of using this function, i just set the value of n to be the number(which i know for this certain file) like instead of the thing above, i just write:
int n=40;
then the program works
W T F......... srsly, its like exactly the same thing yet only one way works and i cant use that way for all input files.
can anyone tell me why????????????????