473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 6036
Banfa
9,065 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

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

Similar topics

3
by: Kapil Khosla | last post by:
Hi, I am trying to move the file pointer back to the original location, but not able to using seekg, can someone help ? Thanks, Kapil #include "stdafx.h" using std::cerr; using std::endl;...
1
by: wtnt | last post by:
Hello. I've searched all over and haven't seen another thread with this problem. Please bear with me as I try to explain. thanks. :) I have some programs that need to be cross-platform...
2
by: Brian Ronk | last post by:
I'm having a strange error. I have a Debian stable server and I'm using gcc 3.3, but it looks like I have 3.4 installed as well. I recently made a change to a program that takes data from two...
2
by: Assertor | last post by:
Hi, All. (VC++6.0) I found some strange thins when using getline() and seekg() of std::ifstream. After the file position of an open file was shift to the end of the file, seekg() did not...
3
by: nomad5000 | last post by:
Hi I'm trying to read a textfile and print it's content twice to the std::cout but it won't work the second time. I think it has something to do with the seekg(0) command but I don't know. here is...
4
by: jewel87 | last post by:
Hello, I have a problem in the following code: OutputFile.clear(); OutputFile.seekg(0); The compiler (Visual Studio) gives an error message: error C2039: 'seekg' : is not a member of...
12
by: Julian | last post by:
Hi, I am having problems with a function that I have been using in my program to read sentences from a 'command file' and parse them into commands. the surprising thing is that the program works...
1
by: fmufti | last post by:
I would like to check if the f_count is a valid position for seekg in the file or not. What I mean is if I pass a position to seekg and that does not exist in the file then e.g if...
2
by: geseeker | last post by:
Hi, i want to move the file pointer to the last 128th byte, so i can read the ID3V1 tag in an mp3 file. Here's my code to test the result of moving the file pointer: #include <iostream> #include...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.