We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,348 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Errors 2446 & 2040

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
4
Contributors
5
Replies
5 Hours
Discussion Span
3 Years Ago
Last Updated
6
Views
smco9
Newbie Poster
6 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

Ancient Dragon
Achieved Level 70
Team Colleague
32,145 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,577
Skill Endorsements: 69

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

smco9
Newbie Poster
6 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

try to type this

if(fn.peek() == '\n' || fn.peek() == EOF)

Look this http://msdn.microsoft.com/en-us/library/ebe3zf17(VS.80).aspx

peek method returns the next character

Protuberance
Junior Poster in Training
90 posts since Aug 2009
Reputation Points: 78
Solved Threads: 17
Skill Endorsements: 0

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

firstPerson
Industrious Poster
4,046 posts since Dec 2008
Reputation Points: 851
Solved Threads: 626
Skill Endorsements: 15

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

Ancient Dragon
Achieved Level 70
Team Colleague
32,145 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,577
Skill Endorsements: 69

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0978 seconds using 2.84MB