title: declaring an array vs allocating memory for it
body: <p>I wrote a function in C that takes 10 integer from the user and prints them out.</p>
  
  <pre><code>void memoryallocationtest(int number)
  {
      // allocate space for 10 integer
      char *input = malloc( 32 * sizeof(char) );
      long *x = malloc( number * sizeof(long) );
      char *ptr;
  
      printf("please enter 10 integer X consecutively, -2147483648 &lt;= X &lt;= 2147483647)\n");
      /* promts user to enter ith integer
       * converts input string to long value and saves result in x
       */
      for(int i = 0; i &lt; number; i++)
      {
          printf( "%i. Integer:", (i + 1) );
          scanf( "%s", input );
          x[i] = strtol( input, &amp;ptr, 10 );
      }
      free(x);
      free(input);
  }
  </code></pre>
  
  <p>Is this an efficient way to do it?</p>
  
  <p>Is there any point of allocating and freeing space for my char-array "input" or should I just declare it like <code>char input[32];</code> or is that what happens implicit anyway?</p>