I believe it is because of the strcmp(). I tried it multiple ways so far and this is just the latest. My objective is to get the index of the array so I can go on to a switch statement to execute code. Any help would be appreciated, although I'm only expecting a "You can't do that."
Big picture is to incorporate this snip of code into a "utility" file that has multiple "functions" and would call it like util("Ping") to execute a Ping and so on...
int main(){
char *cmd = "Ping";
char *names[3]={"Ping","Stop","Go"};
int index = 3;
int i;
char *test;
for (i = 0; i < 44; i++)
{
test = names[i];
if (!strcmp(cmd,test))
{
index = i;
}
}
printf("%s is index of %d\n",cmd,index);}