I\'m having some trouble understanding the difference between these two code segments: I allocate space for an array of integers dynamically within my code with the followin
If you have int arr1[8]
the type of arr1 (as far as the compiler is concerned) is an array ints of size 8.
In the example int * arr2
the type of arr2 is pointer to an integer.
sizeof(arr1)
is the size of an int array
sizeof(arr2)
is the size of an int pointer (4 bytes on a 32 bit system, 8 bytes on a 64 bit system)
So, the only difference is the type which the compiler thinks that variable is.