Constants quiz
Pascal Cuoq - 20th Jan 2012What does the following program print?
long long l;
#include <stdio.h>
int main()
{
l = -0x80000000;
printf(\%lld" l);
}
$ gcc t.c && ./a.out
And this one? (beware trick question)
long long l;
#include <stdio.h>
int main()
{
l = -2147483648;
printf("%lld" l);
}
$ gcc t.c && ./a.out
What "it's too difficult!"? Okay here is a hint in the form of a third question:
long long l;
#include <stdio.h>
int main()
{
l = -2147483648;
printf("%lld" l);
}
$ gcc -std=c99 t.c && ./a.out
You are probably reading this on a computer on which the answers are "2147483648" "2147483648" and "-2147483648".
