My program is accepting user input and then taking the first word inputted and comparing it to an array of accepted commands. What would be the best way to compare the first word inputted (after it has been tokenized) to an array of strings?
Example:
comparing the string "pwd" to an array containging {"wait", "pwd", "cd", "exit"}
Thanks in advance for your help!
in.strncmp. Or he could use tries. Or any number of cool things.const char* cmds[] = {"wait", "pwd", "cd", "exit"};and my program needs to compare a string the user inputs (the first word is stored in a variable) to see if it matches any of the elements incmd.