I don't quite understand why when I run the code, inputting with 5 different strings, it prints string[0] as the last string that I enter:
for example, if I input:
yes
no
it would print:
Check yes
yes
yes
Check no
no
no
even for index=0
int main(void) {
char *string[5];
char entered[11];
for(int j = 0; j < 5; j++) {
scanf("%s", &entered);
string[j] = entered;
printf("Check %s\n",entered);
printf("%s\n",string[j]);
printf("%s\n",string[0]);
}
return 0;
}
My intention is to save each string entry into the array.
So for my example, I want:
Check yes
yes
yes
Check no
no
yes
I am not allowed to use malloc...etc.