I'm trying to pull
printf("%d",0010 ); but displays 8. How can I output 0010?
You give printf octal number 10 and ask to print it as a decimal. You get 8 - did you wait for something else?
There is no format specification for outputting binary numbers, so they must be output manually. As an example:
// Вывод байта в двоичном виде typedef unsigned char byte; int main() { byte b = 93; // Или любое другое for (int i = 0; i < 8; i++) { printf("%c", (b & 0x80) ? '1' : '0'); b <<= 1; } printf("\n"); return 0; } Source: https://ru.stackoverflow.com/questions/944051/
All Articles
printf("%s", "0010");, not? - AnT pm