Recently I started learning c and was experimenting with arrays and passing them between functions.
Now I have written a simple piece of code which has two functions one for generating random numbers and putting them in an array of size 50 and one function to display the contents of the array.

I can pass the array as array[] or *array, what is difference between the two techniques (if there is any) other than not being able to use pointer arithmetic with the former.

Thanks

There's no difference at all. The array notation for a function parameter is just syntactic sugar. Internally it's treated as a pointer, and you can use it as a pointer, which does indeed include pointer arithmetic:

#include <stdio.h>

void traverse(int a[], int n)
{
    while (--n >= 0)
    {
        printf("%d", *a++);
    }
}

int main(void)
{
    int a[] = {1, 2, 3, 4, 5};
    
    traverse(a, sizeof a / sizeof *a);
    
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.