I was solving the question that prints primes up to a limit. I solved after looking at solution. I couldn't understand the use of pointers here.
I have commented the line I don't understand. Also, If I remove that line, I get array filled with 0s Please help me here asked 02 Jan '17, 21:11

I am assuming you know what pointers are and how they work. If not, please take a look here. In summary, a pointer stores the memory address of another variable. Which can be used to change the value of a variable from a different function, for instance. The sieve function you have here is defined as int main(void) { int cnt, i; // cnt will store the number of primes found int *res = sieve(100, &cnt); // ^ here the address of cnt variable is passed to sieve function for(i=0; i< cnt; i++) printf("%d ", res[i]); return 0; } After the sieve function receives the value of the I have tried to document the code it properly so that it's easier to understand, here. Hope this helps, and do ask if something is not clear. answered 02 Jan '17, 23:44
First of all, thanks for your efforts mate. It's my mistake that I didn't tell the use of n, it is used to define the length of array. The line I have problem is n = k. This is the part I didn't understand.
(03 Jan '17, 15:30)
2
It's not "
(04 Jan '17, 00:08)

please provide full solution so I can understand your doubt. answered 02 Jan '17, 21:25

*n = k; answered 03 Jan '17, 06:44
