sscanf problem,
DMINATOR
DMINATOR_member at pathlink.com
Mon Jul 3 15:13:32 PDT 2006
Hi
I have a little strange problem, probably I am doing something wrong.
I am writing a small parser for an 3d .OBJ format. I am using sscanf for
parsing. Most of the results are correct, except one place.
Here is the part of input text file:
g object_1
f 12/934/12 228/1/228 231/936/231
f 228/1/228 72/75/72 229/935/229
f 231/936/231 229/935/229 75/937/75
f 227/2/227 231/936/231 230/10/230
f 72/75/72 695/960/695 1346/3/1346
f 695/960/695 2/1352/2 1345/1328/1345
f 1346/3/1346 1345/1328/1345 73/938/73
f 229/935/229 1346/3/1346 233/939/233
f 654/7/654 232/6/232 75/937/75
f 233/939/233 236/4/236 654/7/654
f 75/937/75 233/939/233 654/7/654
f 644/5/644 236/4/236 233/939/233
f 73/938/73 234/1340/234 644/5/644
f 233/939/233 73/938/73 644/5/644
f 236/4/236 644/5/644 647/940/647
f 644/5/644 234/1340/234 645/859/645
f 647/940/647 645/859/645 646/234/646
f 643/8/643 647/940/647 235/1032/235
f 232/6/232 654/7/654 656/941/656
f 654/7/654 236/4/236 643/8/643
f 656/941/656 643/8/643 655/231/655
f 653/942/653 656/941/656 655/231/655
f 666/15/666 242/943/242 71/9/71
f 230/10/230 244/16/244 666/15/666
f 71/9/71 230/10/230 666/15/666
f 658/12/658 244/16/244 230/10/230
f 75/937/75 232/6/232 658/12/658
f 230/10/230 75/937/75 658/12/658
f 244/16/244 658/12/658 660/11/660
--------------------------
Here is the code I use for reading that :
// 1 Vertex -- 2 Vertex -- 3 Vertex
text.sscanf("f %d/%d/%d %d/%d/%d %d/%d/%d",
&triangles[ arpos ].vertexes[0].vid[0] ,
&triangles[ arpos ].vertexes[0].vid[1] ,
&triangles[ arpos ].vertexes[0].vid[2] ,
&triangles[ arpos ].vertexes[1].vid[0] ,
&triangles[ arpos ].vertexes[1].vid[1] ,
&triangles[ arpos ].vertexes[1].vid[2] ,
&triangles[ arpos ].vertexes[2].vid[0] ,
&triangles[ arpos ].vertexes[2].vid[1] ,
&triangles[ arpos ].vertexes[2].vid[2] );
----
text is char[]
results are just int.
Anyway all the code is parsed pretty well, except for a few places:
12/934/12 228/1/228 231/936/231
228/1/228 72/75/72 229/935/2298 <---- 2298, should be 229 !
231/936/231 229/935/229 75/937/75
227/2/227 231/936/231 230/10/230
72/75/72 695/960/695 1346/3/1346
695/960/695 2/1352/2 1345/1328/1345
1346/3/1346 1345/1328/1345 73/938/73
229/935/229 1346/3/1346 233/939/233
654/7/654 232/6/232 75/937/75
233/939/233 236/4/236 654/7/654
75/937/75 233/939/233 654/7/654
644/5/644 236/4/236 233/939/233
73/938/73 234/1340/234 644/5/644
233/939/233 73/938/73 644/5/644
236/4/236 644/5/644 647/940/647
644/5/644 234/1340/234 645/859/645
647/940/647 645/859/645 646/234/646
643/8/643 647/940/647 235/1032/235
232/6/232 654/7/654 656/941/656
654/7/654 236/4/236 643/8/643
656/941/656 643/8/643 655/231/655
653/942/653 656/941/656 655/231/655
666/15/666 242/943/242 71/9/71
230/10/230 244/16/244 666/15/666
71/9/71 230/10/230 666/15/666
658/12/658 244/16/244 230/10/230
75/937/75 232/6/232 658/12/6583 <---- 6583, should be 658 !
230/10/230 75/937/75 658/12/658
244/16/244 658/12/658 660/11/660
So any ideas, what might be bugging here :) ?
More information about the Digitalmars-d-learn
mailing list