19

Possible Duplicate:
How to printf “unsigned long” in C?

I have my number like so...

int unsigned long number = 600851475143;

I am trying to print it with printf(). Every time I try, I get a warning by the compiler.

I've tried %uld, %ld and Googling hasn't seemed to find me the answer.

I'm learning C, but have not had to use a long int before, so I'm not sure what I should be using.

What is the specifier I am chasing?

Community
  • 1
  • 1
alex
  • 479,566
  • 201
  • 878
  • 984

2 Answers2

35

I recommend using standard order (i.e. unsigned long int). %lu is the format tag you're looking for.

printf("%lu", 5ul);
eq-
  • 9,986
  • 36
  • 38
10
int unsigned long number = 600851475143LU;
printf( "%lu", number );

prints 600851475143

alex
  • 479,566
  • 201
  • 878
  • 984
Kiril Kirov
  • 37,467
  • 22
  • 115
  • 187