|
| jimctu (21) | |||
| hi everyone... I have an array of chars: ifname[50] in this array i can have anything, letters, numbers, special characteres... i have to get the ascii code of the char as a integer... i cannot figure out how to do this... i tried a lot of things...all went wrong: sprintf(m1,"%i",ifname[i]); gives me segmentation fault
gives me strange numbers, such as -1564789432 its very simple, but i have run out of ideas anyone can help me? | |||
| melkiy (128) | |||
| how your ml and ch are defined? Give more info. The code must work:
| |||
| helios (6057) | |||
chars are just integers. You don't need to do anything special to get their values:
I can't imagine how you could have gotten -1564789432 from casting a signed 8-bit integer to a bigger signed integer. It just shouldn't happen. At worst, you should have gotten, say, -128 from a 128 character. | |||
This topic is archived - New replies not allowed.
