Re: code work wrong when i put it in gtk+ application
- From: Carlos Pereira <jose carlos pereira ist utl pt>
- To: gtk-app-devel-list gnome org
- Subject: Re: code work wrong when i put it in gtk+ application
- Date: Thu, 12 Nov 2009 13:51:25 +0000
As Tor already said, you can disable locale settings (and then
everything will work as 15.000000 in every country, not 15,000000)
with gtk_disable_setlocale (), before starting gtk:
gtk_disable_setlocale ();
gtk_init (&argc, &argv);
Carlos
After i updated my system my previously working gtk+ application start to print wrong result.The problem is
atof() i used in the program.The code is working as expected in a standart c console version.(Program reads
some datas from file and make some calculations)The code i used is;
suppose that at line 62 the file have data;
10 5 15 B 15.031103
the code;
gchar *temp,cm[11];
gfloat m;
gint l00;
.....
while(!feof(in)){
fgets(temp,30,in);
for(i=0;i<10;i++) cm[i]=temp[i+15];
cm[10]='\0';
if(l==62) g_print("mass=%s\n",cm);/*prints 15.031103 */
m=atof(cm);
if(l==62) g_print("mass=%f\n",m);/*prints 15,000000 notice that not 15.000000
it prints with the comma 15,000000 */
l++;
}
I also tried sscanf(cm,"%f",&m) and m=strtof(cm,NULL);
always gives 15,000000 When i try exactly the same code in a standart c program it is working as expected.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]