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

unsigned long n;
long m;

printf("%lu %ld", n, m);
Answer from postfuturist on Stack Overflow
🌐
w3resource
w3resource.com › c-programming-exercises › c-snippets › conversion-specifier-for-formatting-long-with-printf-in-c.php
Conversion Specifier for Printing long in C with printf
For printing a long integer, you use the %ld specifier. This specifier tells printf to format the corresponding argument as a long int.
Discussions

Printf long long int in C with GCC? - Stack Overflow
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 convers... More on stackoverflow.com
🌐 stackoverflow.com
Printing long int value in C - Stack Overflow
I have two variables of long int type as shown below: long int a=-2147483648, b=-2147483648; a=a+b; printf("%d",a); I am getting zero. I tried changing the type to long long int, but I'm still not More on stackoverflow.com
🌐 stackoverflow.com
how to print long long int (s64_t) values using printk or printf
Hello, I would like to print signed long long int (s64_t ) values using printk or printf. I tried some suggestions I found online %lli , %lld but they did not More on devzone.nordicsemi.com
🌐 devzone.nordicsemi.com
0
0
February 24, 2021
c - How do you format an unsigned long long int using printf? - Stack Overflow
Moreover, as far as I remember ... C90 compliant by design; C99 introduced some things that not everyone liked. 2009-10-11T20:57:26.6Z+00:00 ... One thing to keep in mind here is that if you are passing multiple long long arguments to printf and use the wrong format for one ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
IncludeHelp
includehelp.com › c › arguments-for-printf-that-formats-a-long-datatype.aspx
Arguments for printf() that formats a long datatype
July 10, 2022 - The format specifier is used for unsigned long int is %lu. signed long long int or long long int: The size of these datatypes is 8 bytes.
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › c-runtime-library › format-specification-syntax-printf-and-wprintf-functions
Format Specification Syntax: `printf` and `wprintf` Functions | Microsoft Learn
For historical reasons, the wprintf ... such as short, int, long, long long, and their unsigned variants, are specified by using d, i, o, u, x, and X....
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › How-to-format-a-Java-int-with-printf-example
How to format a Java int or long with printf example
There are two key takeaways from this Java int printf example: The %d specifier works for long, int, double and short datatypes.
🌐
Wyzant
wyzant.com › resources › ask an expert
How do you format an unsigned long long int using printf? | Wyzant Ask An Expert
May 3, 2019 - #include <stdio.h> int main() { unsigned long long int num = 285212672; //FYI: fits in 29 bits int normalInt = 5; printf("My number is %d bytes wide and its value is %ul. A normal number is %d.\\n", sizeof(num), num, normalInt); return 0; }Output: My number is 8 bytes wide and its value is 285212672l.
🌐
Unstop
unstop.com › home › blog › format specifiers in c — complete list with code examples (2026)
Format Specifiers in C — Complete List with Code Examples (2026)
May 19, 2026 - We declare a long integer variable x and initialize it with the value 123456789 inside the main() function. Then, we print the value of x to the console using the printf() function and the %ld format specifier, which formats the long integer ...
Find elsewhere
🌐
W3Schools
w3schools.com › c › c_data_types_extended.php
C More Data Types (Extended Types)
May 17, 2026 - printf("Size of int: %zu bytes\n", sizeof(int)); printf("Size of double: %zu bytes\n", sizeof(double)); printf("Size of short int: %zu bytes\n", sizeof(short int)); printf("Size of unsigned int: %zu bytes\n", sizeof(unsigned int)); printf("Size ...
🌐
U-Boot Documentation
docs.u-boot.org › en › latest › develop › printf.html
Printf() format codes — Das U-Boot unknown version documentation
The following tables shows the correct combinations of modifiers and specifiers for the individual integer types.
🌐
Quora
quora.com › How-can-I-print-an-unsigned-long-int-in-C-language
How to print an unsigned long int in C language - Quora
Answer (1 of 6): %lu is the standard order for unsigned long int. Just ran this snippet and it works for me. #include int main(void) { int unsigned long number = 600851475143LU; printf( "%lu", number ); return 0; } Let me know if you face some issue with this Vineeta Karki.
🌐
Cplusplus
cplusplus.com › reference › cstdio › printf
Printf
printf · function · <cstdio> int printf ( const char * format, ... ); Print formatted data to stdout · Writes the C string pointed by format to the standard output (stdout).
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_format_specifiers.htm
Format Specifiers in C
C uses %d for signed integer, %i for unsigned integer, %ld or %li for long integer, %o or %O for octal representation, and %x or %X for hexadecimal representation of an integer. The following example highlights how integer format specifiers ...
🌐
NXP
community.nxp.com › t5 › MCUXpresso-General › printf-double-and-unsigned-long-int-support › td-p › 967954
printf(), double and unsigned long int support - NXP Community
June 28, 2019 - where i is declared as uint64_t cast as an unsigned long int equal to 0x100000001 displays as "i = lu". If instead I select Newlib (nohost) in the Library/Header category, the second printf() call shown above will render the expected value, however when the first printf() shown is encountered the hard fault handler is inevitably invoked.
🌐
Cprogramming
cboard.cprogramming.com › c-programming › 60111-displaying-long-long-printf.html
Displaying a 'long long' with printf
December 27, 2004 - For example, MSVC supports 64bit integers using the (compiler-specific) built-in type "__int64". ... I decided to post my original response - although it's not the root cause of trinitrotoluene's problems, it is a problem that's popped up here a few times in the past. In short, you can use the MS C-runtime library (MSVCRT.DLL) with MinGW - and the version of printf() in this library uses "%I64" instead of "%ll" when specifying a 64bit integer.
🌐
Texas Instruments E2E
e2e.ti.com › support › microcontrollers › msp-low-power-microcontrollers-group › msp430 › f › msp-low-power-microcontroller-forum › 199047 › printf-unsigned-long-int-a
printf unsigned long int a; - MSP low-power microcontroller forum - MSP low-power microcontrollers - TI E2E support forums
This has nothing to do with MSP430. The printf implementation is a plain compiler-specific thing. A different compiler (and there are at tlest three I know of) may handle it differently. Even the support for different levels of printf support is not MSP specific.