if you are thinking of the C++ STL type "std::map" you are in the wrong forumsection, otherwise: read on.
tip #1
compare parts of strings (char *):
Code:
#include <string.h>
char *foobar = "hello world!";
if (strncmp("hello", foobar, 4) == 0) { ... }
tip #2
function callbacks:
Code:
void (my_exit_callback)(int);
my_func_callback = &exit; /* assign callback-pointer with the address of exit-function */
my_func_callback(0); /* exit with code 0 */
tip #3
put all information in a struct, then put all your pairs into an array which you can easily loop through to find the correct callback function.
Code:
struct foobar {
char *cmd_key;
void (*cmd_handler)(char *);
}
struct foobar callbacks[] = {
{"PRINT", &print_handler},
{"EXIT", &exit_handler}
};