Jump to content
  • Advertisement
Sign in to follow this  
Sagar_Indurkhya

Urgent! ifstream string won't work!

This topic is 4929 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

Advertisement
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
won't work! why?


Because you made an error.

Tell me in what ways it "won't work", and I'll tell you why.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!