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 to use execvp() to execute a command
- Why is it not possible to fake an IP address?
- How does strtok() split the string into tokens in C?
- Authentication versus Authorization
- What is tail recursion?
- How can I write a `try`/`except` block that catches all exceptions?
- error: called object is not a function or function pointer
- What is activation record in the context of C and C++?
- Get text from user input using C
- Were jprobes removed from kernel v4?
- What fonts can I use with pygame.font.Font?
- CSS Box Shadow Bottom Only
- 2D array vs array of arrays
- How to squash all git commits into one?
- Sign extend a nine-bit number in C
- how to fix Javac invalid flag error?
- What is runtime in context of Python? What does it consist of?
- What are the different versions of exec used for in C and C++?
- mount.nfs: requested NFS version or transport protocol is not supported
- Portable way to check if directory exists [Windows/Linux, C]
- Getting DOM element value using pure JavaScript
- What is the difference between lemmatization vs stemming?
- What’s the meaning of exception code “EXC_I386_GPFLT”?
- Instagram how to get my user id from username?
- What is `S_ISREG()`, and what does it do?
- typedef struct pointer definition
- What is a .meta file and why does Unity create them for all of my assets?
- What’s the difference between sx and σx in the statistics calculations on a TI-Nspire?
- Apache Kafka vs Apache Storm
- Whats the difference between UInt8 and uint8_t
- How to Compare 2 Character Arrays [duplicate]
- How to use redirection in C for file input
- How can an Admin access the Google Drive contents of all the users in a particular domain?
- To remove rendering of menus and header, plugin or theme?
- How to Unban an IP properly with Fail2Ban
- How to see stdout of ansible commands?