How can I fully print the unsigned long int?

Asked 1 years ago, Updated 1 years ago, 74 views

#include <stdio.h>
int main() {
    unsigned long long int num = 285212672; //FYI: fits in 29 bits
    int normalInt = 5;
    printf("%ul" is %d bytes; int value is %d.\n", num, sizeof(num), normalInt);
    return 0;
}

Output: 285212672l is 8 bytes. int value is 0.

It's not supposed to be printed like that normalInt is being output strangely because "%ul" cannot hold all 285212672l ㅜㅜ How do I print unsigned long int?

c syntax printf format-specifiers long-long

2022-09-21 19:45

2 Answers

Put l for long and ll for long To indicate unsigned, attach u.

printf("%llu", 285212672);


2022-09-21 19:45

The devc++ program produces good results without errors.


2022-09-21 19:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.