What is the argument for printf that formats a long?

Thomas Owens picture Thomas Owens · Sep 2, 2008 · Viewed 828.3k times · Source

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.

Answer

postfuturist picture postfuturist · Sep 2, 2008

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

unsigned long n;
long m;

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