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?
- How big can a 64 bit unsigned integer be?
- How do I convert a String to an int in Java?
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- What is a segmentation fault?
- 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
- How do you round UP a number?
- How do you round UP a number?
- How to use execvp()
- How to use execvp() to execute a command
- How does strtok() split the string into tokens in C?
- Java – Convert integer to string [duplicate]
- warning: implicit declaration of function
- warning: implicit declaration of function
- What is the maximum value for an int32?
- What is *(uint32_t*)?
- What does (~0L) mean?
- pthread_join() and pthread_exit()
- Why has the int32 type a maximum value of 2³¹ − 1? [duplicate]
- How can I convert a std::string to int?
- Easiest way to convert int to string in C++
- What is the difference between float and double?
- Converting integer to string in Python
- what is Segmentation fault (core dumped)? [duplicate]
- What causes a segmentation fault (core dump) to occur in C?
- uint8_t vs unsigned char
- How to use symbols of extended ASCII table in C?
- Two questions about basic C programs
- What is the difference between ++i and i++?
- Using boolean values in C
- How can I convert String to Int?
- How to convert a string to an integer in JavaScript?
- What does “collect2: error: ld returned 1 exit status” mean?