I want to be able to modify a struct. I have the following.
struct shopDetails {
char name[MAX + 1];
};
Then I have the following function which I call from main.
void modifyShop(struct shopDetails*shopList, int num)
{
char nameInput[MAX + 1];
printf("Name Of Shop You Want To Modify: \n");
fgets(nameInput, sizeof(nameInput), stdin);
char modifyInput[MAX_NAME_LEN + 1];
printf("New Name For Shop: \n");
fgets(modifyInput, sizeof(modifyInput), stdin);
int i = 0;
while (i < num) {
if (strcmp(shopList->name, nameInput)) {
//shopList->name = modifyInput;
return;
}
shopList++;
i++;
}
printf("Couldn't find shop entered.");
}
I am fairly new to C so sorry if this is a bad question but I couldn't find much on it and was wondering why it doesn't allow me use the code that is commented out.