I want to parse user input commands in my C (just C) program. Sample commands:
add node ID
add arc ID from ID to ID
print
exit
and so on. Then I want to do some validation with IDs and forward them to specified functions. Functions and validations are of course ready. It’s all about parsing and matching functions…
I’ve made it with many ifs and strtoks, but I’m sure it’s not the best way… Any ideas (libs)?
I think what you want is something like this:
You can do what you wish with ‘command’ and ‘arguments’ just before you free it all.