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

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.

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]'

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

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

commented: :icon_wink: +29
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.