Sign in to follow this  
Great_White

about scanf

Recommended Posts

unsigned chars are guaranteed to be the size of a byte. Because of this, you can simply read in a byte (char) and convert it to an integer.

Share this post


Link to post
Share on other sites
value already is an integer, but it's range is limited to values 0-255.

Or do you mean that your input is '0', '1', '2', ....

I'd usually refer to this as single-digit number, rather than 1-byte.

Easiest way would probably be:

int x = value - '0';

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