title: Reading values from console overwrites a struct
body: <p>I made a small program where I have a struct and filling its parameter based on value from console.</p>
  
  <pre><code>#define M 3
  struct data {
      char* info;
      int key;
  };
  
  void initHash(data* d) {
      int i;
      for(i=0; i&lt;M; i++) {
          d[i].info = " ";
          d[i].key = -1;
      }
  }
  
  
  void printList(data* d) {
      int i;
      for(i=0; i&lt; 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",&amp;str);
      while(strcmp(str, "end") != 0) {
      d[id].info = str;
      **printf("before reading \n");
      printList(d);
      id++;
      scanf("%s",&amp;str);
      printf("after reading \n");
      printList(d);
      printf("next iter \n");**
      }
      printList(d);
      return true;
  }
  </code></pre>
  
  <p>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?</p>
  
  <p>Sample output:</p>
  
  <pre><code>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
  </code></pre>