1.11M Members

Errors 2446 & 2040

 
0
 

I'm getting conversion errors 2446 and 2040 on the red line. Can anyone help me figure out what i've done. I'm new to C++ but I'm expereinced in C# so I do have some foundation. Any help is greatly appreciated!

string GetString(ifstream & fn, string & s, int length)
{
     int charCount;
     char ch;
     s.erase();

     for(charCount = 0; charCount < length; charCount++)
     {
     // Stop if there are fewer characters to be read than expected
     [B]if(fn.peek() == "\n" || fn.peek() == EOF)[/B]
	break;
     else
     {
	ch = fn.get(); // Read next character including blanks
	s = s + ch; // and append it to the string
     } // end else
} // end for that reads in characters
return s;
} // end function GetString
 
0
 

Error numbers mean absolutely nothing because they are compiler specific. Post the actual error message for those numbers -- most compilers print messages as well as error numbers.

 
0
 

error C2446: '==' : no conversion from 'const char *' to 'int'
1> There is no context in which this conversion is possible

error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'

 
0
 

"\n" and '\n' are completely different. One is a string literal which is
null terminated while other is a newline character.

 
0
 

>>I don't like smiley faces.
:);):D:-O:S:ooh::sweat::icon_eek:

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: