Re: strtod() asking for ',' like decimal point???



mån 2006-04-03 klockan 09:21 -0300 skrev Marcelo David:
> Hello!
> 
> I'm in Brazil.
> 
> Look this code:
> 
> ---- start
> char *pChar;
> g_print("Literal to Double value = %10,5g", strtod(
> (const char*) "3.14151692", &pChar );
> g_print("Literal to Double value = %10,5g", strtod(
> (const char*) "3,14151692", &pChar );
> ---- end
> 
> on console I had:
> 
>    3,00000
>    3,14152
> 
> My Operating System (Linux/Windows) is configured to
> use ',' (comma) like decimal point.
> 
> I don't know how to inform strtod() to ignorate the
> locale of Operating System and convert using '.' like
> decimal point.

Maybe you can use:

#include <locale.h>

...

setlocale(LC_ALL, "en_US");
// or
setlocale(LC_NUMERIC, "en_US");

I guess something like that would do it.
Not sure what GTK does, though. Maybe it overrides this somehow?

//Marcus

> 
> I'm using g++ on Linux and Dev-C++ on Windows.
> 
> Thanks.
> 
> (o_o)
> Marcelo David
> 
> 
> 		
> _______________________________________________________ 
> Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. Registre seu aparelho agora! 
> http://br.mobile.yahoo.com/mailalertas/ 
> 
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list




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