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#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c# - Making TableLayoutPanel Act Like An HTML Table (Cells That Resize Automatically Around Text) -