Sign in to follow this  

Urgent! ifstream string won't work!

This topic is 4717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

EDIT: Sorry if I was spreading misinformation. I tried to find evidence in MSDN that the >> operator is defined for string objects, but failed. Since I had never used it before myself, either, I assumed that it did not exist.

[Edited by - mumpo on January 17, 2005 10:24:16 PM]

Share this post


Link to post
Share on other sites
Ignore the previous

std::string does work with input stream >> operators.
What problems exactly are you having? List the compile errors

btw: How on earth did you get such a low rating ? 00

[Edited by - ProPuke on January 17, 2005 12:31:25 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Sagar_Indurkhya
fixed it. Another question however.

suppose i am working with C, and have

long long a = 0;

how could i use scanf("...", &a);

???

thanks for all the help so far though!


long long a = 0;
scanf("%ll", &a);

Share this post


Link to post
Share on other sites
I edited out my earlier apply, since it was apparently incorrect. However, MSDN doesn't list istream::operator>>(string&) or anything like that that I could find. Can someone post me a link proving that it is part of the STL? Obviously one could easily just make an operator like that, but I want to see the evidence that it is supposed to be predefined.

Share this post


Link to post
Share on other sites
Quote:
Original post by mumpo
I edited out my earlier apply, since it was apparently incorrect. However, MSDN doesn't list istream::operator>>(string&) or anything like that that I could find. Can someone post me a link proving that it is part of the STL? Obviously one could easily just make an operator like that, but I want to see the evidence that it is supposed to be predefined.


That's because its part of the string class itself. Here is the link for that operator and this one for all of them.

- Drew

Share this post


Link to post
Share on other sites
Quote:
Original post by mumpo
I edited out my earlier apply, since it was apparently incorrect. However, MSDN doesn't list istream::operator>>(string&) or anything like that that I could find.
It's not a member:
istream & operator >> (istream & is, std::string & s);

Quote:
Can someone post me a link proving that it is part of the STL?
It's not part of the STL, either. STL is the name for a proprietary library developed by HP and SGI which was largely adopted as the basis for the Standard C++ Library. In many respects, you could consider the Standard C++ Library to be the sum of the Standard Template Library and IOstreams, plus the Standard C Library.

It took some digging, but I found this documentation for you.

Share this post


Link to post
Share on other sites
@Drew_Benton and Oluseyi: Thank you for the links. That is strange that the operator is defined externally though. I would guess that they did it that way in order to not give it access to private members, since it doesn't need it to get the job done, and to avoid requiring that a project use string if it is going to use istream.

Share this post


Link to post
Share on other sites

This topic is 4717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this