I can never understand how to print unsigned long datatype in C.
unsigned long
Suppose unsigned_foo is an unsigned long, then I try:
unsigned_foo
%lu is the correct format for unsigned long. Sounds like there are other issues at play here, such as memory corruption or an uninitialized variable. Perhaps show us a larger picture?
%lu