Subject: c++ question regarding tellg()
From: John Schmidt (jas@netbrick.com)
Date: Wed Jan 09 2002 - 17:39:50 MST
Hi,
I am wondering why the tellg() is only declared in iostream.h in the following
rpms:
gcc-2.95.4-4h
gcc-c++-2.95.4-4h
gcc-g77-2.95.4-4h
Using gcc on an SGI, things appear to work but not on my ydl 2.1 version with
the latest g++ compiler.
Here is the sample code stream_test.cc
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
string name("John");
istringstream instream(name);
instream.seekg(1);
cout << "tellg() " << instream.tellg() << endl;
cout << "string buf = " << instream.rdbuf()->str() << endl;
cout << "length of buf = " << instream.rdbuf()->str().size() << endl;
cout << name << endl;
return 0;
}
compiling with: c++ -o stream_test stream_test.cc
and running: ./stream_test results in the following:
[jas@retriever jas]$ ./stream_test
tellg() 268526225
string buf =
length of buf = 0
John
This is clearly not right. Am I missing some development rpms or is the g++
compiler for ppc not complete in this regard.
Thanks,
John Schmidt
jas@netbrick.com
This archive was generated by hypermail 2a24 : Wed Jan 09 2002 - 17:54:38 MST