List:General Discussion« Previous MessageNext Message »
From:古雷 Date:March 16 2006 1:33am
Subject:Re: insert my_ulonglong data with C API
View as plain text  
 Nelson:

Thanks a lot.

I found that sprintf(s,"%llu\n",ull.id); works with gcc but not with VC6.0 .

Thanks.

Regards,
Gu Lei

----- Original Message ----- 
From: "Dan Nelson" <dnelson@stripped>
To: "??????" <leig@stripped>
Cc: <mysql@stripped>
Sent: Wednesday, March 15, 2006 11:27 PM
Subject: Re: insert my_ulonglong data with C API


> In the last episode (Mar 15), ?????? said:
>> Thanks a lot! But my test is not successful. Please help me. This is
>> my test code:
>> 
>> #ifdef WIN32
>> #include <windows.h>
>> #endif
>> 
>> #include "mysql.h"
>> #include <stdio.h>
>> main()
>> {
>>  union ull {
>>   unsigned char a[8];
>>   my_ulonglong id;
>>  } ull;
>>  for(int i=0;i<8;i++) ull.a[i]=(unsigned char)255;
>>  
>>  char s[200];
>>  sprintf(s,"%llu\n",ull.id);
>>  printf("%s\n",s);
>> 
>>  return 0;
>> }
>> 
>> On Windows its output is:
>> 4294967295
>> It's still a 4bytes integer.
> 
> Maybe your compiler doesn't understand the %llu syntax.  If it's a
> posix-compatible compiler, try this (although if it was posix, %llu
> would have worked, so this probably won't either):
> 
>  #include <inttypes.h>
> 
>  ...
> 
>  sprintf(s,"%"PRIu64"\n",ull.id);
> 
> Or read your compiler documentation to verify that can print 64-bit
> integers at all.
> 
> -- 
> Dan Nelson
> dnelson@stripped
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=leig@stripped
>
Thread
insert my_ulonglong data with C API古雷15 Mar
  • Re: insert my_ulonglong data with C APIDan Nelson15 Mar
  • Re: insert my_ulonglong data with C API古雷15 Mar
    • Re: insert my_ulonglong data with C APIPooly15 Mar
    • Re: insert my_ulonglong data with C APIDan Nelson15 Mar
  • Re: insert my_ulonglong data with C API古雷16 Mar