sigsegv error again and again for factorial problem in easy. I AM new please help!

int main()
int n;
int totline,ptr,i;
scanf("%d", &totline);
for( i=0; i<totline ;i++)
{ scanf("%d", &n);
( ptr+i)=0;
printf("%d\n", *(ptr+i));
return 0;

1 Like

Please refer this: SIGSEV errors answers here

1 Like

To help you a little more…

…link provided by @namankumar is correct.

This part is related to you:

Make sure you aren’t declaring too much memory. 64 MB is guaranteed, but having an array of size [10000][10000] will never work.

N is up to 109, so how big memory you need for calloc(n,sizeof(int)); ? Let’s assume, that size of int is 4 bytes :wink:

then how should i declare memory based on the input of n,pls help?

but calloc() will initialize the memory booking based on the if i say n is small(depends on input) then it allocate only n*4 bytes which is good.

But N can be as big as I wrote, so you cannot assume it is small. You have to find another approach…