Why do I get a SIGSEGV?

I got SIGSEVG error when my code compiled.In my code, I declared a 2D array of size N,and according to the constrains given in the problem ,N can be any integer upto 10^5,How do i overcome this ??
Please help me out.

why do i get SIGSEVG ERROR please check this link CodeChef: Practical coding for everyone

Why am I getting runtime error (SIGSEGV) I dont understand?
CodeChef: Practical coding for everyone.
Please help me anyone.

why am i getting SIGSEVG ? CodeChef: Practical coding for everyone Please help me anyone as soon as possible.

use static memory allocation ,not dynamic (y) this causes SIGSEVG error sometimes

3 Likes

Most of the questions in codechef have plenty of memory if you allocate it properly to the arrays. So, use it freely to declare large arrays. If you need more memory than needed, maybe you’re taking the wrong approach. So, avoid using sigsegv and use plenty of memory.

Please upvote if this helped you.

#include<stdio.h>
int main()
{
int t,n,v[10],i,j=0,big=0;
static int c[10];
scanf("%d",&t);
while(t–)
{
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&v[i]);
++c[v[i]];
}
big=0;
for(i=1;i<=n;i++)
{
if(c[i]>big)
{
big=c[i];
j=i;
}
c[i]=0;
}
printf("%d %d\n",j,big);

}
return 0;
}

HELP ME OUT FOR THIS RUN TIME ERROR SIGSEVG…HIGHLY IMPORTANT
PLSS
LINK: CodeChef: Practical coding for everyone

PLS PLS HELP ME OUT…

i am getting an error please help me. My code is correct i checked it with codechef compiler also - CodeChef: Practical coding for everyone

What if we need to put an array of 100000 ints inside a function ?
Rest everything is correct.But i m still getting SIGSEGV error:(

Somebody please help me with this… CodeChef: Practical coding for everyone

please help , why do i get RUNTIME ERROR (SIGSEGV)
https://www.codechef.com/viewsolution/9965435

please help , why do i get RUNTIME ERROR (SIGSEGV)
https://www.codechef.com/viewsolution/9965435

https://www.codechef.com/viewsolution/9994477
why do i get SIGSEVG

@thepranay14 you are getting segsigv because in question the upper limit of n i.e the number of elements in array p is 100000 but you are storing just 9997. when you got the value of n from stdin then it may contain a value of 100000 and your for loop will for(i=0;i<n;i++){ scanf("%d",&p[i])} will expect the size of p[] to be around 100000. this is the reason you are getting a sigsegv

why do i get a runtime error sigsegv for this problem? pls help.#include<stdio.h> int main() { int k, n; while(n<=10000000&&k<=10000000) scanf("%d", &n); scanf("%d", &k); int t[n]; int i; while(i<n&&t[i]<=1000000000) { scanf("%d\n", &t[i]); i++; } int count = 0; for (i = 0; i < n; i++) { if (t[i] % k == 0) count = count + 1; } printf("%d", count); }

Why I am getting SIGSEGV error on TSORT problem. I am using C and here is my Solution

why do i get SIGSEGV in this code please help me…
https://www.codechef.com/viewsolution/10061505

please help why do i get sigsegv in this code CodeChef: Practical coding for everyone

#include<stdio.h>
int main()
{
int r,i,j,k,l,p,q,x;
int n,m,T;
int B[n],A[n-m];
scanf("%d",&T);
for(k=0;k<T;k++)
{
scanf("%d%d",&n,&m);
for(r=0;r<n;r++)
{B[r]=0;
}

 	 for(l=0;l<m;l++)
 	 {
 	 	 scanf("%d",&x);
 	 	 B[x-1]=1;
	  }
	  
for(i=0,j=0; i<n,j<n-m; i++)
{
	 if(B[i]==0)
	 A[j++]=i+1;
	 
 }
 
 for(q=0;q<n-m;q=q+2)
 {printf("%d ",A[q]);
  A[q]=0;
	   }	
printf("\n");	   
		     
for(p=0;p<n-m;p++)
	  {
	  	if(A[p]!=0)
	  	printf("%d ",A[p]);
	  }
	printf("\n");	  
	  
	  
	   }
	   return 0;

}

why am i getting this error here???pls help