I was doing problem 2.1 of K&R C which basically wants us to mess around and understand the header library
#include<stdio.h>
#include<limits.h>
#include<float.h>
int main()
{
printf("%lu", ULONG_MAX);
}
When I run this program, I get the output
4294967295
which is equal to 232 -1. I was expecting this value (since K&R has the same value in it's appendix).
Now I changed %lu
to %llu
.
With my little knowledge of the C language, I am assuming that %llu
is a bigger 'placeholder' for the value of ULONG_MAX
.
I expected to get the same output, but instead I got a vague output
38654705663
Isn't ULONG_MAX
supposed to be a constant? Why is it changing?
Also, in quest for an answer, I stumbled upon this.
I understand the argument that the standard mentions the term 'minimum' but when I tested this with CHAR_MAX
(i.e. tried to print CHAR_MAX
with a %llu
specifier), I got
38654705663
This is contradictory to everything I have ever read about char
in C.
Really hope that someone clears the confusion regarding this.