Looking for Help: fstream objects, .getline(), and strings

Hi guys,

I'm having a bit of an issue. I'll just show you my code.
1
2
3
4
5
6
7
const string EQUAL40 = string(40, '=');
fstream inFile;
inFile.open("filename");
string inputLine = inFile.getline();

while((inFile.eof() == false)  && (inputLine != EQUAL40))
{...}


These are the errors I'm getting from this code:
the call to infile.getline() gives me
no instance of overloaded function
. Also, in the while statement condition inputLine != EQUAL40 the != operator says it
does not match the operands


So basically, I'm not sure why an input stream cannot use the .getline() method, or why it seemingly won't compare a const string to a
string


This is for an assignment, so any help you guys can give is definitely appreciated.
RTFM
1
2
3
4
5
6
7
//std::istream::getline
istream& getline (char* s, streamsize n );
istream& getline (char* s, streamsize n, char delim );

//std::getline
istream& getline ( istream& is, string& str, char delim );
istream& getline ( istream& is, string& str );


the != operator says it
does not match the operands
paste the full message.
Alright, though I'm a little surprised, since I've never had to pass parameters to a getline() call before, and it's always worked fine.

Well, this being the case, I suppose I need a way to do what I was trying to do with that line in the first place. That is, get a line of input and put it in a string variable.

As for the other error message, here it is:
Error: no operator "!=" matches these operands


There you go.

Again, any suggestions are a help.
Thanks.
The operation is valid, it should not issue a compile error.
┬┐Have you included the headers?

I can't believe that's the full message either.
Both fstream and iostream are included.

Sorry, I should have been more specific about the "error." It's not a compile error (the code isn't presently in a state that will compile), the "error" is Visual Studio spitting a red line at me. That short message is what it shows me when I mouse over it. I've monkeyed around a little to see if VS is trying to pull one over on me, but regardless if I change things or retype the code, it's consistently giving me this warning.

I'm probably another hour away from a compileable project, so I've just had to truck on and hope I can work this out.
Topic archived. No new replies allowed.