I made a small program where I have a struct and filling its parameter based on value from console.
#define M 3
struct data {
    char* info;
    int key;
};
void initHash(data* d) {
    int i;
    for(i=0; i<M; i++) {
        d[i].info = " ";
        d[i].key = -1;
    }
}
void printList(data* d) {
    int i;
    for(i=0; i< M; i++) {
        if(strcmp(d[i].info, " ")) {
            printf(" %d %d %s \n", i, d[i].key, d[i].info);
        }
    }
}
int linearProbing() {
    struct data d[M];
    int hashval;
    char* info;
    char str[25];
    initHash(d);
    scanf("%s",&str);
    while(strcmp(str, "end") != 0) {
    d[id].info = str;
    **printf("before reading \n");
    printList(d);
    id++;
    scanf("%s",&str);
    printf("after reading \n");
    printList(d);
    printf("next iter \n");**
    }
    printList(d);
    return true;
}
My issue is in the highlighted lines the first print function prints correct value but after getting input , the data.info param changes to the new input value for all the M members of struct array. Can someone explain why it might be so?
Sample output:
statue
before reading 
 0 -1 statue 
tornado
after reading 
 0 -1 tornado 
next iter 
before reading 
 0 -1 tornado 
 1 -1 tornado 
clown
after reading 
 0 -1 clown 
 1 -1 clown 
next iter 
before reading 
 0 -1 clown 
 1 -1 clown 
 2 -1 clown
 
     
    