Archived

This topic is now archived and is closed to further replies.

Zerosignull

Parsing String's Help!?

Recommended Posts

Zerosignull    122
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~

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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);

Share this post


Link to post
Share on other sites
BeerNutts    4401
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

Share this post


Link to post
Share on other sites