Storing "binary" data type in C program

Posted by puchu on Stack Overflow See other posts from Stack Overflow or by puchu
Published on 2012-10-13T03:31:53Z Indexed on 2012/10/13 3:36 UTC
Read the original article Hit count: 149

Filed under:

I need to create a program that converts one number system to other number systems. I used itoa in Windows (Dev C++) and my only problem is that I do not know how to convert binary numbers to other number systems. All the other number systems conversion work accordingly. Does this involve something like storing the input to be converted using %?

Here is a snippet of my work: case 2: { printf("\nEnter a binary number: "); scanf("%d", &num); itoa(num,buffer,8); printf("\nOctal %s",buffer); itoa(num,buffer,10); printf("\nDecimal %s",buffer); itoa(num,buffer,16); printf("\nHexadecimal %s \n",buffer); break; } For decimal I used %d, for octal I used %o and for hexadecimal I used %x. What could be the correct one for binary? Thanks for future answers!

© Stack Overflow or respective owner

Related posts about mysql-error-1064