title: Adding User Input To An Array (C)
body: <p>beginner in C here. Sorry for the lame question. I've writing a program that takes ten integers from the user and then adds them to an array. It works, but for some reason it prompts the user 13 times for an integer, and doesn't include the "Please enter an integer:" part on the second prompt. Otherwise it still creates the array and saves the first ten numbers. I just can't get it to stop asking for integers 13 times. </p>
  
  <pre><code>int main () {
  
      FILE fp*
      int *arr = (int*) malloc (sizeof(int)*10);
  
      for(int i=0;i&lt;=10;i++)
      {
              printf("Enter an integer:");
              scanf("%d", &amp;arr[i]);
      }
      for (int i=0; i&lt;11; i++)
      {
              printf("arr[%d] = %d: \n", 10-i-1, arr[10-i-1]);
      }
   return 0;
  }
  </code></pre>
  
  <p>This is how it currently runs:</p>
  
  <blockquote>
    <p>Enter an integer:1</p>
    
    <p>Enter an integer:2</p>
    
    <p>Enter an integer:3</p>
    
    <p>Enter an integer:4</p>
    
    <p>Enter an integer:5</p>
    
    <p>Enter an integer:6</p>
    
    <p>Enter an integer:7</p>
    
    <p>Enter an integer:8</p>
    
    <p>Enter an integer:9</p>
    
    <p>Enter an integer:10</p>
    
    <p>Enter an integer:11</p>
    
    <p>Enter an integer:12</p>
    
    <p>arr[9] = 10: </p>
    
    <p>arr[8] = 9: </p>
    
    <p>arr[7] = 8: </p>
    
    <p>arr[6] = 7: </p>
    
    <p>arr[5] = 6: </p>
    
    <p>arr[4] = 5: </p>
    
    <p>arr[3] = 4: </p>
    
    <p>arr[2] = 3: </p>
    
    <p>arr[1] = 2: </p>
    
    <p>arr[0] = 1:</p>
  </blockquote>