Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] result_normal_plus[2]='\0' likely clobbers payload (was Re: issues with format of double (or IEEE754))



"Stephen J. Turnbull" wrote:

> Have you tried
> 
>     result_normal_plus[2] = '\0';
>     printf ("header = '%s'\n", result_normal_plus);

Unless a backup copy of result_normal_plus[2] is made first, 
result_normal_plus[2]='\0'; is likely to clobber the 
binary data payload. 

It'd be better to deal with the two ASCII character as 
just two ASCII characters (that are not in a string), 

   printf("header = '%c%c'\n", result_normal_plus[0],result_normal_plus[1])

or to _copy_ them into a nul-terminated string. 

   header[0]=result_normal_plus[0];
   header[1]=result_normal_plus[1];
   header[2]='\0';
   printf("header = '%s'\n", header);



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links