title: Loop only running once: while and for (c)
body: <pre><code>void abScores()
  {
  int i, choice, abScore[6], abScoreTwo[6];
  char abS[6][5] = {"Str", "Dex", "Con", "Int", "Wis", "Cha"};
  FILE *fp;
  FILE *fo;
  fp = fopen("csheet.txt", "a");
  
  printf("Would you like your own ability scores, or the basic ability scores?\n");
  printf("1 for own, 2 for basic\n");
  scanf("%d", &amp;choice);
  
  if (choice == 1)
  {
      for (i = 0; i &lt; 6; i++)
      {
          abScore[i] = roll();
          printf("Ability score %d: %d\n", i+1, abScore[i]);
      }
  }
  else if (choice == 2)
  {
      abScore[0] = 15;
      abScore[1] = 14;
      abScore[2] = 13;
      abScore[3] = 12;
      abScore[4] = 10;
      abScore[5] = 8;
      for (i = 0; i &lt; 6; i++)
          printf("Ability score %d: %d\n", i+1, abScore[i]);
  }
  
  i = 0;
  while (i &lt; 6)
  {
      printf("What score would you like for %s?\nPlease use each score only once.\n", abS[i]);
      for (i = 0; i &lt; 6; i++)
      {
          printf("%2d\n", abScore[i]);
      }
      //scanf("%d", &amp;abScoreTwo[i]);
      i++;
  }
  
  for (i = 0; i &lt; 6; i++)
      fprintf(fp, "%s: %d\n", abS[i], abScoreTwo[i]);
  }
  </code></pre>
  
  <p>This loop only seems to run once when run in the main function. I've also tried running it as a for loop, but it only runs once. Could anyone tell me why this is happening? The function is supposed to take input from a function called roll() that rolls a six-sided die to four places in an array, adds them together, gets the lowest, then subtracts the lowest from the sum, then puts it into an array in the abScores() function. It only runs once, but I want it to run six times for the function to actually work.</p>