Sign in to follow this  
pavel989

error C2440, char [2] to char?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this