I keep getting negative numbers for long in printf

Asked 2 years ago, Updated 2 years ago, 88 views

long mylong = 1000000000000000000;
printf("%d", mylong);

Output: -1486618624

I don't know what you call that %d thing I don't think all the long types go in ㅜㅜ If I write %f, it looks like 0.0000 so what should I do?

c printf

2022-09-22 12:01

1 Answers

Specify %, %d or %i are known as format specifiers.

The format specifier for long attaches l immediately after the specifier.

unsigned long n;
long m;

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


2022-09-22 12:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.