So i'm trying to read in a string of characters twice using cin.get(). The input is being redirected as "program < input". So it is valid to use seekg().
As the titel says, I thought I would be able to use seekg() to save the beginning position of the string, so I could come back to use the starting position of the same string again.
Here is my attempt:
char c;
while (cin.get(c))
{
//do stuff
}
cin.seekg(0, ios::beg);
while (cin.get(c))
{
//do stuff with the string a second time
}
The second while loop isn't doing anything, so I'm obviously not using seekg correctly. Could someone tell me what I'm doing incorrectly?
Thanks for any help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…