How to remove first element in multidimentional array?

Why isn't the address of the array itself the same as the address of the first element in an array when the array is passed as an parameter to a C function?

  • Let's say I have a function defined as void f(int a[]) and an array defined as int b[] = {1,2,3}. In function f, I print the address of a and the address of a[0], but find out that they are not the same. Why would this happen?

  • Answer:

    Your function doesn't really take in an array, but rather a pointer to an int.  The address of a is the address of that pointer (local to your function); the address of a[0] is within the array and is in fact the same as the value of a.

Jelle Zijlstra at Quora Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.