How to print a hexadecimal value of 255 on Unix?

can you tell me

How to use printf to search for hexadecimal and octal values ​​255?

Many thanks.

+3
source share
2 answers

Try using the specifier oandx printf

printf("%d %o %x",255,255,255); // prints 255 377 ff

If you want to do this on the shell, you can do:

$ printf "%o\n" 255
377
$ printf "%x\n" 255
ff
$ 
+6
source

Try the following:

printf("%x", 255);  /* print hex representation of decimal 255 */
printf("%o", 255);  /* print octal representation of decimal 255 */
+1
source

Source: https://habr.com/ru/post/1763730/


All Articles