kevin@iti.org (Kevin Wallace) (04/25/91)
I am "porting" code developed using AT&T C++ Release 2.1 to G++ v1.37.
My problem is this:
How do you associate a string with the input stream in g++ -
ie. read from a string with operator >> instead of from cin ?
Below is a cutdown excerpt of what I'm doing in AT&T C++ that I'd like to
imitate in g++.
// The program:
// ----------------------------------------------------------------------------
#include <strstream.h>
#include <stream.h>
#include <string.h>
int main()
{
char buf[256];
char word[16];
strcpy(buf,"Hello world");
istrstream ss(buf);
ss >> word; cout << word << "\n";
ss >> word; cout << word << "\n";
}
// ----------------------------------------------------------------------------
// Run output:
// ----------------------------------------------------------------------------
Hello
world
// ----------------------------------------------------------------------------
Kevin
(kevin@pleiades.newcastle.edu.au)