RE: [gtk-list] string to double (or float) conversion




Make sure you include an appropriate header file to get the strtod
definition, otherwise it will assume int. Try:

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

void main()
{

char *ch;
float f;
ch = "2345.235";
f = strtod (ch,NULL);
printf("%f\n", f);
}

-tony


On 20-Mar-2000 Nilton S. Ramos Quorin wrote:
> Hello,
> I'm having trouble to do a string to double conversion. I have the
> following simple code which doesn't work:
> 
> char *ch;
> float f;
> ch = "2345.235";
> f = strtod (ch,NULL);
> 
> I compiled my code with a Glade make.  When i compile it with a
> simple
> gcc command, it works.
> I tried to set the environment variable LC_ALL to en_US
> Is there a gtk function for this special purpose?
> Thanks,
> Nilton
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
> /dev/null

---
E-Mail: Tony Gale <gale@syntax.dera.gov.uk>
Democracy is a form of government in which it is permitted to wonder
aloud what the country could do under first-class management.
		-- Senator Soaper

The views expressed above are entirely those of the writer
and do not represent the views, policy or understanding of
any other person or official body.



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