Hey everyone, I am getting a compile error in my code, and I cannot figure out what to do. Here's the block:
#include <stdio.h>
#include <string.h>
/*
* Function to return index at which team ID input is stored
*/
int getIndex(char* id, char* idList[][50]) {
int k;
for (k=0; k<50; k++) {
if (strcmp(id,idList[k])==0) {
return k;
}
}
printf("Error in getIndex function.\n");
return -1;
}
and the error says
Passing argument 2 of 'strcmp' from incompatible pointer type
The error occurs on the 8th line of code in the block (the if statement).
EDIT (posted here on behalf of Michael, since he can't edit his posts yet)
I'll specify what I wanted to do, since I didn't really do a good job at that.
I wanted id[] which is just supposed to be a array of up to 50 characters to be compared with idList[][] which is an array of Strings (up to 50 Strings up to 50 characters each).
I changed my code to this,
/*
* Function to return index at which team ID input is stored
*/
int getIndex(char* id[], char* idList[][50]) {
int k;
for (k=0; k<50; k++) {
if (strcmp(id[],idList[k][])==0) {
return k;
}
}
printf("Error in getIndex function.\n");
return -1;
}
but got an error saying:
Expected expression ']' before token