Try:
printf("%04x",a);
0
– Left-pads the number with zeroes (0) instead of spaces, where padding is specified.4
(width) – Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is right justified within this width by padding on the left with the pad character. By default this is a blank space, but the leading zero we used specifies a zero as the pad char. The value is not truncated even if the result is larger.x
– Specifier for hexadecimal integer.
More here
Related Posts:
- max value of integer
- printf() formatting for hexadecimal
- Printing hexadecimal characters in C
- %i or %d to print integer in C using printf()?
- C’s printf and fprintf(stdout,) are not printing
- What do numbers using 0x notation mean?
- How many spaces for tab character(\t)?
- How to convert an int to string in C?
- What is a string of hexadecimal digits?
- How to convert an int to string in C?
- Correct format specifier for double in printf
- Compiler Error “void value not ignored as it ought to be” in C programming [duplicate]
- Scanf/Printf double variable C
- C compiler for Windows?
- Why the range of int is -32768 to 32767?
- Strings and character with printf
- What is the argument for printf that formats a long?
- How to convert an int to string in C?
- What is the printf format specifier for bool?
- How to convert an int to string in C?
- How to printf “unsigned long” in C?
- How I can print to stderr in C?
- Is there a printf converter to print in binary format?
- C – The %x format specifier
- How to convert integer to string in C?
- What does “%.*s” mean in printf?
- How to print a char array in C through printf?
- c array – warning: format not a string literal
- How to printf a memory address in C
- Data argument not used by format strings in C
- How can one print a size_t variable portably using the printf family?
- How can you print multiple variables inside a string using printf?
- Check if input is integer type in C
- error: aggregate value used where an integer was expected
- Why are hexadecimal numbers prefixed with 0x?
- How to print an unsigned char in C?
- Valgrind Invalid free() / delete / delete[] / realloc() in C
- Is there a way to have printf() properly print out an array (of floats, say)?
- Is there any difference between 1U and 1 in C?
- error: unknown type name ‘bool’
- How do you allow spaces to be entered using scanf?
- How to write to a file using open() and printf()?
- Using floats with sprintf() in embedded C
- Printf width specifier to maintain precision of floating-point value
- Which of sprintf/snprintf is more secure?
- Does C have a string type?
- Execution of printf() and Segmentation Fault
- printf format specifiers for uint32_t and size_t
- How to repeat a char using printf?
- Representing EOF in C code?
- warning: return makes pointer from integer without a cast but returns integer as desired
- Two decimal places using printf( )
- How do you format an unsigned long long int using printf?
- How to read from input until newline is found using scanf()?
- What primitive data type is time_t? [duplicate]
- Reading float using scanf in c
- How to format strings using printf() to get equal length in the output
- Reading float using scanf in c
- How to format strings using printf() to get equal length in the output
- What do \t and \b do?
- write() to stdout and printf output not interleaved?
- Example of realpath function in C
- How to convert integers to characters in C?
- How to print a int64_t type in C
- How big can a 64 bit unsigned integer be?
- Using prevNext Modx Addon
- How to convert decimal to hexadecimal in JavaScript
- Convert hex color to RGB values in PHP
- :wq! command in vim
- how to set the background color of the status bar during the launching phase [duplicate]
- api-ms-win-crt-runtime-l1-1-0.dll is missing when opening Microsoft Office file [closed]
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- What is a segmentation fault?
- When is K 1024 and when is it 1000?
- What is a MIME type?
- Implementing Taylor Series for sine and cosine in C
- Working on code to calculate cosine with factorial sum
- Generate unique random numbers between 1 and 100
- Logitech/LGHUB Lua – Loop with break
- are there dictionaries in javascript like python?
- How do you round UP a number?
- How can I convert MP3 file to a Base64 encoded string? [closed]
- Understanding The Modulus Operator %
- Understanding the main method of python [duplicate]
- Dial pad to get phone number (with Android button images)
- How do you round UP a number?
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- How to use execvp()
- How is the AND/OR operator represented as in Regular Expressions?
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- How to use execvp() to execute a command
- Istio Ingress resulting in “no healthy upstream”
- Why is it not possible to fake an IP address?
- How to open a “-” dashed filename using terminal?
- Substring in excel
- What is a LAMP stack?
- What is a sanity test/check
- What is the difference between POST and PUT in HTTP?
- What is the difference between POST and PUT in HTTP?
- How to find Google’s IP address?