FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sscanf problem

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
DMINATOR



Joined: 20 Jun 2006
Posts: 15
Location: Tallinn, Estonia

PostPosted: Thu Jul 06, 2006 12:52 am    Post subject: sscanf problem Reply with quote

Hi

I found a little strange problem, when using sscanf:

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:

Quote:

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 :
Code:

// 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] );



But here is what I get as a result:

Quote:

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


I tried to reproduce the problem with a new project, but error dissappeared. I have no idea what is causing the problem.

I have uploaded the 2 projects, one is with and another without error, you can find it here http://adogames.com/programming/problem.zip

P.S. Is there D analog of sscanf ?

P.S.S. Another problem I can't reply or create new post at digitalmars newsgroup page somehow, they are just don't get showed.
Back to top
View user's profile Send private message MSN Messenger
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Thu Jul 06, 2006 11:14 am    Post subject: Re: sscanf problem Reply with quote

DMINATOR wrote:
P.S.S. Another problem I can't reply or create new post at digitalmars newsgroup page somehow, they are just don't get showed.
I think that your messages are being posted (e.g. digitalmars.D.learn:3827, digitalmars.D.learn:3823) -- they just don't show up right away. There's some kind of delay before web interface posts show up. I've seen it. Just a little patience is required.

It's generally better if a newsgroup readers is used to read those newsgroups, but that's not an option for everyone. For more information, see Wiki4D:NewsDmD.

As far as your actual programming questions go, people have replied to your newsgroup posts, and I think you'll find them more useful than any advice I could provide.
Back to top
View user's profile Send private message AIM Address
DMINATOR



Joined: 20 Jun 2006
Posts: 15
Location: Tallinn, Estonia

PostPosted: Thu Jul 06, 2006 11:50 am    Post subject: Re: sscanf problem Reply with quote

jcc7 wrote:
DMINATOR wrote:
P.S.S. Another problem I can't reply or create new post at digitalmars newsgroup page somehow, they are just don't get showed.
I think that your messages are being posted (e.g. digitalmars.D.learn:3827, digitalmars.D.learn:3823) -- they just don't show up right away. There's some kind of delay before web interface posts show up. I've seen it. Just a little patience is required.

It's generally better if a newsgroup readers is used to read those newsgroups, but that's not an option for everyone. For more information, see Wiki4D:NewsDmD.

As far as your actual programming questions go, people have replied to your newsgroup posts, and I think you'll find them more useful than any advice I could provide.


Thats the problem I posted once without the problem, now I just can't reply to them !. Or even make a new post, I tried it about 7 times without any luck. 2-3 days ago.

Still thanks for the link, I am going to try and post the reply using my opera news reader, If I have any luck at all.

Yes Opera helped, my replies, now finally arrive. It seems there are some problems with web interface.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group