They are completely equivalent when used with printf()
. Personally, I prefer %d
, it’s used more often (should I say “it’s the idiomatic conversion specifier for int
“?).
(One difference between %i
and %d
is that when used with scanf()
, then %d
always expects a decimal integer, whereas %i
recognizes the 0
and 0x
prefixes as octal and hexadecimal, but no sane programmer uses scanf()
anyway so this should not be a concern.)
Related Posts:
- How to display hexadecimal numbers in C?
- How many spaces for tab character(\t)?
- What is size_t in C?
- How to convert an int to string in C?
- How to convert an int to string in C?
- Correct format specifier for double in printf
- Scanf/Printf double variable C
- Why use conio.h?
- Why the range of int is -32768 to 32767?
- max value of integer
- Strings and character with printf
- printf() formatting for hexadecimal
- Printing hexadecimal characters in C
- 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?
- Difference between int32, int, int32_t, int8 and int8_t
- Is there a printf converter to print in binary format?
- Reading \r (carriage return) vs \n (newline) from console with getc?
- How to convert integer to string in C?
- How to check whether a int is not null or empty?
- What does “%.*s” mean in printf?
- How to print a char array in C through printf?
- C char* to int conversion
- 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?
- Convert char array to a int number in C
- C convert floating point to int
- 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
- How to print an unsigned char in C?
- C’s printf and fprintf(stdout,) are not printing
- 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?
- What do numbers using 0x notation mean?
- How do you allow spaces to be entered using scanf?
- How to write to a file using open() and printf()?
- How do you clear the console screen in C?
- Using floats with sprintf() in embedded C
- Printf width specifier to maintain precision of floating-point value
- Preventing console window from closing on Visual Studio C/C++ Console application
- Which of sprintf/snprintf is more secure?
- Does C have a string type?
- Execution of printf() and Segmentation Fault
- Why is the sizeof(int) == sizeof(long)?
- printf format specifiers for uint32_t and size_t
- How to repeat a char using printf?
- Simple C scanf does not work? [duplicate]
- 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?
- What primitive data type is time_t? [duplicate]
- Reading float using scanf in c
- How to run Ruby code from terminal?
- How to format strings using printf() to get equal length in the output
- Reading float using scanf in c
- How to run Ruby code from terminal?
- 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?
- How to convert integers to characters in C?
- What causes a segmentation fault (core dump) to occur in C?
- How to use symbols of extended ASCII table in C?
- Arrow operator (->) usage in C
- Why does the terminal show “^[[A” “^[[B” “^[[C” “^[[D” when pressing the arrow keys in Ubuntu?
- How to go from fopen to fopen_s
- Write to .txt file?
- How does Python manage int and long?
- How do I create an array of strings in C?
- wait(null) and wait(&status) C language and Status
- printf with std::string?
- Python ? (conditional/ternary) operator for assignments
- What’s the difference between a file descriptor and file pointer?
- How to do scanf for single char in C
- How to generate a random number between 0 and 1?
- Break statement not within loop or switch in C
- How to properly malloc for array of struct in C
- c++ parse int from string [duplicate]
- C++ array assign error: invalid array assignment
- Allocating string with malloc
- How to simply convert a float to a string in c?
- Is there a replacement for unistd.h for Windows (Visual C)?
- What is the difference between char array and char pointer in C?
- Does stack grow upward or downward?
- error C2371: ‘functionname’ redefinition: different basic types
- configure: error: cannot run C compiled programs
- note: previous implicit declaration of ‘point_forward’ was here
- How to search in commit messages using command line?
- How does the fscanf function work?
- char array not assignable
- Warning: comparison of distinct pointer types
- Text progress bar in terminal with block characters
- stack around the variable…was corrupted
- %p Format specifier in c
- How to check if I’m in screen session?