![]() |
2010-04-05
, 23:27
|
Posts: 49 |
Thanked: 41 times |
Joined on Apr 2010
|
#2
|
![]() |
2010-04-05
, 23:34
|
Posts: 252 |
Thanked: 252 times |
Joined on Nov 2009
|
#3
|
It would be a big bug in libc if that really happened without any problems in the source code. Most probably, it's just a bad code. Do you have a small example of the fscanf call and a file on which it fails?
while(fscanf(file, "%s", buf) != EOF) { switch(buf[0]) { case '#': /* comment */ /* eat up rest of line */ fgets(buf, sizeof(buf), file); break; case 'v': /* v, vn, vt */ switch(buf[1]) { case '\0': /* vertex */ fscanf(file, "%f %f %f", &vertices[3 * numvertices + X], &vertices[3 * numvertices + Y], &vertices[3 * numvertices + Z]); numvertices++; break; // ...
v 0.956776 2.407918 1.846345 v -1.020031 2.407918 1.846345 v 1.097976 2.223070 1.697290 v -1.161232 2.223070 1.697290 v 1.203877 2.096724 1.467326 v -1.267132 2.096724 1.467326 v 0.762625 1.936465 1.582468 v -0.825880 1.936465 1.582468 v 0.762625 2.094863 1.789404 v -0.825880 2.094863 1.789404 v 0.762625 2.343815 1.892402 v -0.825880 2.343815 1.892402 v 0.586125 2.419122 1.916050 v -0.649380 2.419122 1.916050 v 0.427274 2.242678 1.819275 v -0.490529 2.242678 1.819275
for(int i = 0; i < numvertices; i++) { qDebug() << "out" << vertices[i]; }
![]() |
2010-04-06
, 01:39
|
Posts: 49 |
Thanked: 41 times |
Joined on Apr 2010
|
#4
|
![]() |
2010-04-06
, 09:06
|
|
Posts: 1,637 |
Thanked: 4,424 times |
Joined on Apr 2009
@ Germany
|
#5
|
~$ locale LANG=de_DE LC_CTYPE="de_DE" LC_NUMERIC=de_DE LC_TIME=de_DE ....
~ $ locale -ck decimal_point LC_NUMERIC decimal_point =","
![]() |
2010-04-06
, 19:50
|
Posts: 252 |
Thanked: 252 times |
Joined on Nov 2009
|
#6
|
setlocale(LC_NUMERIC, "en_US");
Running an application using the library on a Ubuntu desktop works flawlessly, but when running on a real N900 device it reads out only the integers -1, 0 and 1 - which are not even the rounded equivalents of the floating point numbers in the file!
I could of course dive into reading the file using Qt instead, with hope that it would fix the problem, but I'm wondering if this is a common issue or whether it could be fixed in some other way?