title: Referenced memory could not be written
body: <p>Whenever I run this struct, I can get down to the line where you would input the constitution modifier and the program crashes with a popup window which reads "The instruction at 0x00000000775AFDE9 referenced memory at 0x000000007758D250. The memory could not be written. Press OK to terminate." Here's the struct in question:</p>
  
  <pre><code>struct player_info create_player(void);
  struct player_info{
      char name[30];
      int Level, Str, Dex, Con, Int, Wis, Cha;
  };
  
  struct player_info create_player(void){
      struct player_info aPlayer;
      {
          char c;
          int i;
          printf("Enter Player Name: ");
          scanf("%s",aPlayer.name);
          i = strlen(aPlayer.name);
          do{
              scanf("%c", &amp;c);
              aPlayer.name[i++] = c;
          }
          while (c != '\n');
          aPlayer.name[i - 1] = 0;
      }
  
      printf("Level: ");
      scanf("%d",aPlayer.Level);
  
      printf("Strength Modifier: ");
      scanf("%d",aPlayer.Str);
  
      printf("Dexterity Modifier: ");
      scanf("%d", aPlayer.Dex);
  
      printf("Constitution Modifier: ");
      scanf("%d", aPlayer.Con);
  
      printf("Intelligence Modifier: ");
      scanf("%d", aPlayer.Int);
  
      printf("Wisdom Modifier: ");
      scanf("%d", aPlayer.Wis);
  
      printf("Charisma Modifier: ");
      scanf("%d", aPlayer.Cha);
      return aPlayer;
  };
  </code></pre>
  
  <p>And the write bit:</p>
  
  <pre><code>int save_data(){
               FILE* PlayerFile = fopen("players.txt","w");
               int i = 0;
  
               for (i = 0; i &lt; 1; i++){
               struct player_info aPlayer = create_player();
               fprintf(PlayerFile, "%s %d %d %d %d %d %d %d\n", aPlayer.name, aPlayer.Level, aPlayer.Str, aPlayer.Dex, aPlayer.Con, aPlayer.Int, aPlayer.Wis, aPlayer.Cha);
               }
               fclose(PlayerFile);
               return 0;
               }
  </code></pre>
  
  <p>Now, to be clear, I can input up to the dexterity modifier. The next line that should ask for the constitution doesn't print, and that's when I get the popup error.</p>
  
  <p>I have tried commenting out everything from the constitution mod down to the charisma just to see, and I get the same problem. Removing just the constitution part doesn't work either. I'm not really sure what's going on here; I've seen other posts saying something about a pointer being wrong, but I don't see anything like that, unless it's just one of those things that you just miss and need someone else to point it out. Anyway, any help is appreciated.</p>