Re: [gtk-list] Re: Heisenberg was right?
- From: Kevin Handy <kth srv net>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Heisenberg was right?
- Date: Wed, 10 Jun 1998 17:33:54 -0600
At 11:34 PM 6/10/98 +0200, you wrote:
>> and:
>>
>> char *convert_to_char(double data)
>> {
>> char *c;
>> static char buffer[10];
>
>you allocate a ten byte buffer for this number, now look at:
>"2,22222e+10"
>this number has *11* chars, you are writing beyond the char array
It actually requires 12 characters of storage (Don't forget the \0
to end the string). Not allocating for the terminator seems to be
a common problem, which has caused me many strange problems.
>bounds.
>try
>static char buffer[64];
>or something similar.
>
>>
>> sprintf (buffer, "%g", data);
>> if(data==N_A)
>> sprintf (buffer, "N/A");
>> c=buffer;
>> /* printf("buffer:%g\n",data); */
>>
>> return c;
>> }
>
-------------------------------------------------------------
Kevin Handy kth@srv.net Accounting Software for
Software Solutions. Inc. VAX/VMS Computer Systems
Idaho Falls, Idaho
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]