× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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 :).

#include<string.h>
#include<stdio.h>
#include<stdlib.h>

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

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

}




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.