Forgive me if this is somewhat basic.
If have an array of 20 strings defined:
char const commands[20][20] = {// each command string will have a maximum of 20 chars.
"quit",
"open",
"save",
"close"
};
I want to test the command value to see what action should be taken.
int in_array(char array[], char txt[], int len){
for(int i=0;i<len;i++){
if(txt==array[i][0]){
return i;
}
}
return -1;
}
What is the best way of doing this?
I am currently getting an error:/home/dave/projects/fullpage/action.cpp:15:20: error: invalid types ‘char[int]’ for array subscript
I'd hapily use include <strings>
but I get a similar error.