Hello
I have a program that is working how I want it, but I am distressed by a compiler warning. I therefore assume I have poor code and would like to know if this is the case.
Basically what I have is the following:
- A linked list containing these nodes
Code:
struct node{
int number;
char *ID;
struct node *next;
};
- I then have a function which takes an ID and tries to find if the ID is currently present in the list. If it is, then return the number associated with the ID. Else I need to display the name of the ID that isn't in the list
Code:
int Getnumber(char *name[]){
search = head; //set searchptr to head of the list
while (search->next != NULL){
if (search->ID == *name){
return search->number;
}
search= search->next;
}
if (search->ID == *name){
return search->number;
}
else{
printf("ID %s is not in the list\n",name);
exit(1);
}
}
Given that I call the function like so : Getnumber(ID); where ID is defined as char *string;
any idea why I get this warning message?
Code:
warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char **’
Regards,
James