Parsing String's Help!?

Started by
2 comments, last by Zerosignull 22 years, 8 months ago
Has ne body got ne good ieas on how about going about the extrating of the "Origin" data from the following text? { "classname" "info_player_deathmatch" "angle" "273" "origin" "464 -32 -216" } ~prevail by daring to fail~
Advertisement
char* originpos;
// set originpos to first letter in the word origin
originpos = strstr( text, "\"origin\"");
// move originpos up to the first number
originpos += strlen( "\"origin\" \"");
int part1, part2, part3;
// convert string to number
part1 = atoi( originpos);
// move to next space
originpos = strstr( originpos, " ");
originpos += strlen( " ");
part2 = atoi( originpos);
// move to next space
originpos = strstr( originpos, " ");
originpos += strlen( " ");
part3 = atoi( originpos);
Casn u point me to some tutorials so i can beter under stand what some of those funstions do like

strstr();
atoi();

~prevail by daring to fail~
strstr() and atoi() are in the standard C libraries. Look in any reference book. I suggest buying "The C Programming Language" by Kernighan and Ritchie, the guys who basically wrote the C language. It''s a great reference book.

Nutts

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

This topic is closed to new replies.

Advertisement