Greetings everyone.
I'm a little new to programming in C, just programming for fun. Right now I'm working on a text based adventure game done with the curses library. One of the things I want to do is have an inventory system where the user can collect items and use them later. To store the list of items in inventory, I declared an array of character pointers like so:
Code:
char *list[5] = {NULL, NULL, NULL, NULL, NULL};
Then, later on, when the user types something like "take wallet" I have code that analyzes the string and, if the wallet hasn't already been taken, stores "wallet" in list[0]. That code looks like this:
Code:
if (strcmp(&list[0], "wallet") != 0) {
list[0] = "wallet";
printw("You have taken the wallet.\n");
home0(); //this function is where the wallet is found
}
else {
printw("You already have the wallet.\n");
home0();
}
Whenever it compiles, I get a warning about strcmp, which says "passing argument 1 of 'strcpy' from incompatible pointer type." I read somewhere that all warnings should be fixed. When I run the program though, everything works as expected. If that is the case, should I really be worried about this warning? And if so, what exactly is it that I'm doing wrong?