title: Print array function in C prints only the first element
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12634723/how-to-get-the-size-of-dynamically-allocated-2d-array">How to get the size of dynamically allocated 2d array</a>  </p>
  </blockquote>
  
  
  
  <p>I can't find what I did wrong here. I want to create an array which its size is based on user input, get the data (integers) for the array from user input, and print the array integers.</p>
  
  <p>The problem is that it only prints the first array element, i.e <code>intArr[0]</code>.</p>
  
  <pre><code>int main()
  {
      int i, n, *intArr;
  
      printf("Type the array size:\t");
      scanf("%d", &amp;n);
  
      intArr = (int *)malloc(n * sizeof(int));
  
      for (i = 0; i &lt; n; ++i)
      {
          printf("Type a number\t");
          scanf("%d", intArr + i);
      }
  
      printArr(intArr);
  }
  
  void printArr(int *arr)
  {
      int i; 
      for (i = 0; i &lt; (sizeof(arr) / sizeof(*arr)); ++i)
          printf("%d ", *(arr + i));
  }
  </code></pre>