Problem in prime sieve

Why we us primesiev( int *p) instead of primesiev(int p[n])? what is the benefit of using *p?

@itismohiton you can use anyone they both are same. many use *p as it is shorter to write.
hope your doubt is cleared dont forget to mark it resolved in my doubts section :smiley:

1 Like

I have one more doubt.
suppose you have define an array as arr[n], and here n is user input.
And now you pass this array to a function, how will you do that?
like i want to pass this in primesieve(int arr[n]). Is it correct?

yes you can pass it like that too no issue it will work fine

anything else @itismohiton?

you can also pass it like int a[ ] then you are not bound by size

but when i pass like this it gives me error.

oh i checked the problem is that you can pass it like func(int a[ ]) or func(int a[100]) or func(int *a)
if you want to pass like func(int a[n]) then you have to define n as #define n 100

but i want n as user input.

so you can’t pass it like func(int a[n]) //incorrect
correct func(int a[ ] , int n) // correct this way your array from main gets in this a[] array and you have also
passed the size n which u have taken input

It gives error of unknown array size,

no its working fine let me send you a photo . it shows how i passed it

are you passing it like this? @itismohiton

Doubt resolved thank you sir.