C : Convert signed to unsigned -


actually i've (probably) "simple" problem. don't know how cast signed integer unsigned integer.

my code :

signed int entry = 0; printf("decimal number : "); scanf("%d", &entry); unsigned int uentry= (unsigned int) entry; printf("unsigned : %d\n", uentry); 

if send unsigned value console (see last code line), signed integer.

can me?

thanks lot!

kind regards, pro

printf("unsigned : %u\n", uentry); //                 ^^ 

you must use %u specifier tell printf runtime uentry unsigned int. if use %d printf function expect int, reinterpret input signed value.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -