title: "struct" objects with "for-loop" in C Programming
body: <p>This code is about 'struct' in C..</p>
  
  <p>I created a struct spieler with the properties name and age..
  By using the for-loop I let the user to create the struct objects.
  they are named as sp[i] --> sp1, sp2 etc.</p>
  
  <p>the problem is the objects are created. But I can use them only inside the for-loop.
  If I want to get the value of "sp1.name" in main function, it doesn't work.
  How can I solve it?</p>
  
  <pre><code>struct spieler{
    char name[20];
    int age;
  };
  
  void erzeuge();
  
  int main() {
  
  int anzahl = 2;
  printf("Anzahl Spielern: ");
  scanf("%d",&amp;anzahl);
  
  erzeuge(anzahl);
  
  printf("Es sind %d Spielern",anzahl);
  /*for(i;i&lt;anzahl;i++){
      printf("%d.%s",i, sp[i].name);
  }*/
  
  getchar();
  
  }
  
  void erzeuge(int anzahl){
  
  int i=0;
  for(i;i&lt;anzahl;i++){
      struct spieler sp[i];
      printf("Struct fuer Spieler_%d wurde erzeugt\n", i);
      getchar();
      printf("Name: ");
      scanf("%s",sp[i].name);
  
      printf("%s\n",sp[i].name);
  }
  </code></pre>
  
  <p></p>