Hi,
I'm trying to develop a gtk+ interface which needs to read float values from a file using fscanf.
I found out that if I'm going to read a file before gtk_init() everything goes well (code below):
Code:
int main (int argc, char *argv[])
{
FILE *fi;
strcpy(name, argv[1]);
if ((fi=fopen(name,"r"))==NULL)
{
printf("Error opening input file\n");
return EXIT_FAILURE;
}
while (fscanf(fi,"%g",&y)!=EOF)
{
printf("%g\n",y);
g_usleep(1000000);
}
fclose(fi);
gtk_init(NULL,NULL);
...
In this first case the output reports
Code:
0.003
0.002
0.001
which indeed is the content of the file.
while if I put the read-code just before gtk_init() (which is actually what I need to do) as in the following code:
Code:
int main (int argc, char *argv[])
{
FILE *fi;
strcpy(name, argv[1]);
if ((fi=fopen(name,"r"))==NULL)
{
printf("Error opening input file\n");
return EXIT_FAILURE;
}
gtk_init(NULL,NULL);
while (fscanf(fi,"%g",&y)!=EOF)
{
printf("%g\n",y);
g_usleep(1000000);
}
fclose(fi);
...
the result is an infinite print of:
Code:
0
0
0
...
I was wondering if it's somehow related to the arguments of gtk_init(&argc,&argv);:
Thanks in advance