123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|563|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> Parsing text in C ??

Mon, 18 Jan 2010, 14:20
spinal
Ok, I have one app, outputting a text file as follows -


but im completely stumped as to how I go about reading this text into a couple of arrays.
I would like to read this text into the following arrays -

Icons[number].filename
Icons[number].game_title
Icons[number].game_code

so that I end up with something like -

Icons[0].filename = "fat:/022-MunkyBlocks.nds"
Icons[0].game_title = ". ê "
Icons[0].game_code = "####"
Icons[1].filename = "fat:/SensitiveDS.nds"
Icons[1].game_title = ". ê "
Icons[1].game_code = "####"
etc.
note, the " are only there to show that they are strings.

How the hell do I do this?

-=-=-
Check out my excellent homepage!
Mon, 18 Jan 2010, 15:09
Jayenkai
That's assuming that works in DS-based-C, I remember it having a multitude of "Standard String" issues, enough that I gave up and just ended up avoiding strings at all costs, except for the absolute bare essentials..

If strtok doesn't work, (unable to test, absolutely no devkit installed!!) it's just a case of running through and splitting it up where txt[n]=44..



Maaaan, I'm WAY outta practice with that!!
Far too much BlitzMax lately!
There's bound to be loads of fooks with that code!

As always, check string limits, and that kinda stuff.

-=-=-
''Load, Next List!''
Tue, 19 Jan 2010, 23:48
spinal
OK, I got this far...


but it's merging the last two strings into one
so from "file.ext,........,####" I'm getting
"file.ext" "........####" ""

Any ideas?

-=-=-
Check out my excellent homepage!
Wed, 20 Jan 2010, 01:04
Cower
Try something like this:


By the way, you'll have to call free(..) on the returned pointer when you're done with it.
Wed, 20 Jan 2010, 11:03
spinal
I tried Agent's code again, and it seems to be working fine, not sure what went wrong the first time. Anyway, now I have a weird 'wont load a file that is really truly there' problem, probably unrelated. I never got to test your code cower... sorry.

-=-=-
Check out my excellent homepage!