[SDL] slightly OT: need help w/ file-parsing for game

Cameron Matheson cmatheson3 at hotpop.com
Fri Nov 22 12:11:02 PST 2002


Hi,

I'm trying to write a tile-engine for my game, but unfortunately i'm not 
very good at stuff like string parsing in c/c++.  Originally i 
implemented all this in ruby, where it was very easy (simple language + 
regexp support = happy me), but in c/c++ i'm kindof at a loss (despite 
the easy format).  Anyway, this is basically how i'm storing information 
in my tileset file:

Name: Foo
Description: something about Bar
Tiles: 2
Name: Grass,grass.bmp,#,1
Name: Mountain,mntn.bmp,^,2

Anyway, the spec isn't too important, i just need to know how to get the 
'Foo' seperate from the 'Name: ' and also how to parse the data between 
the commas.  I was thinking probably something like strchr() might work, 
but i thought i would consult the experts.  (I was hoping i could 
somehow incorporate awk into a c program, but that doesn't look possible).

Thanks!
Cameron Matheson






More information about the SDL mailing list