Convert char to int

Jan 31, 2014 at 10:34pm
This weeks assignment has to do with using a convert char to int. My problem is I don't have the slightest idea why you would want to do that or what you would use it for. I don't want the answers just any possible hints or pointers on how this function could be useful. Thanks!

Jan 31, 2014 at 10:39pm
Characters are really just 1 byte integers(0-256). The character representation is based off the ascii value. So you can directly assign the value of a character to an integer or return the value of it. Another method is to cast it to an integer.

I'm not sure what you are trying to do exactly.

Are you trying to change '0' to 0 or get the ascii value of any characters?

Jan 31, 2014 at 11:02pm
closed account (j3Rz8vqX)
One Idea:

String parsing may require you to be able to identify numeric content from other contents.

Ascii Reference:
http://www.asciitable.com/
Jan 31, 2014 at 11:04pm
Actually, the char type can store a value of -127 to 127. I think you're referring to an unsigned char that has a value from 0 to 255.

I pretty much agree with everything else you're saying.

----

Sometimes using datatypes that use the least memory are ideal for embedded systems where RAM is scarce.
Feb 3, 2014 at 4:33pm
Thanks everyone for your responses
Topic archived. No new replies allowed.