How do I printf long long int
and also unsigned long long int
in C99 using GCC?
I have searched the other posts which suggest to use %lld
but it gives these warnings:
warning#1: unknown conversion type character 'l' in format [-Wformat]|
warning#2: too many arguments for format [-Wformat-extra-args]|
For the following attempt:
#include <stdio.h>
int main()
{
long long int x = 0;
unsigned long long int y = 0;
printf("%lld\n", x);
printf("%llu\n", y);
}
You can try settings of code::block
, there is a complier..., then you select in C mode.
Try to update your compiler, I'm using GCC 4.7 on Windows 7 Starter x86 with MinGW and it compiles fine with the same options both in C99 and C11.
For portable code, the macros in inttypes.h may be used. They expand to the correct ones for the platform.
E.g. for 64 bit integer, the macro PRId64
can be used.
int64_t n = 7;
printf("n is %" PRId64 "\n", n);
Source: Stackoverflow.com