Here is my code:
#include <string>
extern std::string commands[];
extern std::string shortcuts[];
int in_array(std::string ar[], std::string txt){
for(int i=0;i<ar->size();i++){
int g=ar->compare(txt);
if(!g){
return i;
}
}
return -1;
}
int actioncmd(char* command){
int act=in_array(shortcuts,command);
if(act==-1){
return -1;
}
act=in_array(commands,command);
return act;
}
I'm simply trying to find out whether a command given by the user is in an array of commands, and, if it is, I want the index.
This is the error:
multiple definition of `in_array(std::string*, std::string)'
I don't have this defined anywhere else, so I thought perhaps there is an existing function called "in_array". So I renamed my function to "in_array_c". Now the error message is:
multiple definition of `in_array_c(std::string*, std::string)'