string strFile;
ifstream input("theFile.txt", std::ios_base::in);
input >> strFile;
Urgent! ifstream string won't work!
I have this:
have all the right headers
won't work! why?
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]
[Edited by - mumpo on January 17, 2005 10:24:16 PM]
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]
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]
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.
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!
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!
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);
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.
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
Quote:Original post by mumpoIt's not a member:
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.
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.
@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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement