0

The way I have passed pointer to arrays in c is like down below:

int main(void) {
    mergesort(arr);
}
void mergesort(int* arr) {
    /*some code*/
}

However, in the code featured in this site, https://www.geeksforgeeks.org/merge-sort/, the author writes code like this:

int main(void) {
    mergesort(arr);
}
void mergesort(int arr[]) {
    /*some code*/
}

Which raised the question, is arr[] same as arr in this situation?

The only time I saw arr[] being used was when I initialized an array omitting the size like this:

arr[] = {1, 2, 3};
the
  • 131
  • 4
  • 3
    Duplicate of [Passing an array as an argument to a function in C](https://stackoverflow.com/questions/6567742/passing-an-array-as-an-argument-to-a-function-in-c) – Siguza Nov 17 '19 at 17:00
  • Do also note that the ordering of the function *definitions* is significant, lacking function declarations. The author does not write the functions in that order. – Antti Haapala Nov 17 '19 at 17:04
  • The link provided by @Siguza above should definately give you some sort of a solution to what yo looking for – Hakim Marley Nov 17 '19 at 17:38
  • @Siguza I checked the link and it helped thanks – the Nov 19 '19 at 07:00

0 Answers0