C

Asked • 04/18/19

How to printf "unsigned long" in C?

I can never understand how to print `unsigned long` datatype in C.Suppose `unsigned_foo` is an `unsigned long`, then I try:* `printf("%lu\\n", unsigned_foo)`* `printf("%du\\n", unsigned_foo)`* `printf("%ud\\n", unsigned_foo)`* `printf("%ll\\n", unsigned_foo)`* `printf("%ld\\n", unsigned_foo)`* `printf("%dl\\n", unsigned_foo)`And all of them print some kind of `-123123123` number instead of `unsigned long` that I have.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.