468,512 Members | 948 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

cin.seekg() problem

i am trying to use the seekg(offset, base) function to move the read position but cant seem to do it correctly. When i use tellg() to know if the seekg operation is
successful or not , the tellg() will always return -1. Heres the code.

#include <iostream>

using namespace std;



int main()
{

char ch;

cin.get();

cin.seekg(0, ios::end);

cout<<cin.tellg();


system("PAUSE");
return 0;
}




Please help me out .. i cant sleep like this :(
Aug 12 '06 #1
1 5408
Banfa
9,056 Expert Mod 8TB
using seek and tell works on files but not on the standard input and output streams because there is no-where to seek to on an input or output stream.
Aug 13 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Kapil Khosla | last post: by
2 posts views Thread by Brian Ronk | last post: by
3 posts views Thread by nomad5000 | last post: by
12 posts views Thread by Julian | last post: by
1 post views Thread by fmufti | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.