Getting stuff from a string
Hi. What''s a good way to get a command and its arguments from a string? Say the user enters a command and some args in a console or whatever, how should I go about extracting the individual parts of the resulting string in order to use them properly?
Thanks in advance.
---
No game will ever rule more than CBT!
---Mikael Lax
Well, you could parse the string and use something like a space to denote seperate args. WHat I mean by parse is go through the string looking for spaces, and seperate the args that way. THen you can match the command to a big command table that holds the command strings and their corresponding action, and you could use the args depending on what command they entered.
You can always use sscanf (stdio.h, ANSI C) or write your own string parsers (which are pretty easy to write, actually).
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement