That's because %u is an "unsigned int" -- but you've used a (signed) long long instead of an unsigned int.

You need to use %lld (ll=long long, d=integer).

printf("num = %017lld\n", num);

On 1/29/2010 5:20 PM, hockchai Lim wrote:
ok. Now, I'm having problem converting this long long (64 bits) num back to
a string. I use %017u and it gives me a 00000000000000001. Why oh why
(can't c be a bit smarter :).


int main(void)
long long num;
char sBuf[30];

sprintf(sBuf, "6027461692 ");
num = atoll(sBuf);
printf("num = %017u\n", num); // the result num = 00000000000000001


This thread ...


Return to Archive home page | Return to MIDRANGE.COM home page