Re: code work wrong when i put it in gtk+ application
- From: Chris Vine <chris cvine freeserve co uk>
- To: cet cet <xnidos yahoo com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: code work wrong when i put it in gtk+ application
- Date: Thu, 12 Nov 2009 00:52:51 +0000
On Wed, 11 Nov 2009 16:35:23 -0800 (PST)
cet cet <xnidos yahoo com> wrote:
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.
The radix is locale dependent. You will need to set a C locale.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]