Jump to content
  • Advertisement
Sign in to follow this  
pavel989

error C2440, char [2] to char?

This topic is 3659 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

char change(char strng[2]) { switch(strng[0]) { case 0: { strng[0]="9"; break; } case 3: { strng[0]="6"; break; } } y does it need to convert? how do i convert it? or is this impossible? as an explanation, this function is taking in a hex value, and testing its values and changing them. Would this even work? I mean i have to test for both characters and numbers.

Share this post


Link to post
Share on other sites
Advertisement
I don't know why you get this error message, or which line it is, but I think you should put 6 and 9 between ' intead of " since it's a single character, not a string.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dunge
I don't know why you get this error message

actually because "9" has type char[2] which cannot be implicitely converted to char ;)

OP, you may be able to rewirte your function like this:

char change(char strng)
{
switch(strng[0])
{
case 0:
return '9';
case 3:
return '6';
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!