Using format specifiers for signed integers
Signed integers include integers that can have negative as well as positive values. The next example program is signedInt.c
, and it begins as follows:
#include <stdio.h>
int main( void ) {
int smallInt = 12;
int largeInt = 0x7fffffff; // int32 max
int negativeInt = -smallInt;
unsigned anUnsigned = 130;
long long int reallyLargeInt = 0x7fffffffffffffff; // int64 max
// the other code snippets go here.
}
The values of smallInt
, largeInt
, negativeInt
, anUnsigned
, and reallyLargeInt
will be printed using various fields, precision, and alignment modifiers. Notice that largeInt
is given a hexadecimal value that is the largest positive value a 32-bit integer can hold. Likewise, reallyLargeInit
is given a hexadecimal value that is the largest positive value a 64-bit...