Hey I'm trying to read in one value at a time from a file with this function, but its giving me back junk. I have tried everything I know can somebody help me please??
Yes, I'm doing this just to make sure that the function is reading from the beginning of the input file. There is another place in my program which uses this same file to get the sum of the values in the file, so I just wanted to make sure that it is reading from the front.
And yes the code you have above works for me too, I don't understand why its not working inside my function though. That's exactly the code I have it should be working.
Wasn't that meant to be something like success = inF >> num;? Otherwise that output parameter is left unused.
Either way, works for me, after adding the missing #includes
Perhaps check the success of inF1.open(), instead of just calling ios::clear() regardless.
Calling ios::clear() resets your streams internal error flags, but if there was a genuine problem with opening the stream in the first place, then you're just ignoring it and whatever you read from such an invalid stream is likely to be junk.