What is the argument for printf that formats a long?

Viewed 1002279

The printf function takes an argument type, such as %d or %i for a signed int. However, I don't see anything for a long value.

7 Answers

Put an l (lowercased letter L) directly before the specifier.

unsigned long n;
long m;

printf("%lu %ld", n, m);

I think you mean:

unsigned long n;
printf("%lu", n);   // unsigned long

or

long n;
printf("%ld", n);   // signed long

I think to answer this question definitively would require knowing the compiler name and version that you are using and the platform (CPU type, OS etc.) that it is compiling for.

Related