can anyone help me…why i am getting SIGSEVG error in this PeQwg9 - Online C Compiler & Debugging Tool - Ideone.com
thanks in advance
can anyone help me…why i am getting SIGSEVG error in this PeQwg9 - Online C Compiler & Debugging Tool - Ideone.com
thanks in advance
#include<stdio.h>
main()
{
long long t=0,i=0,j=0,temp=0,a[10000];
scanf("%lld",&t);
for(i=0;i<t;i++)
scanf("%lld",&a[i]);
for(i=0;i<t-1;i++)
{
for(j=0;j<t-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(i=0;i<t;i++)
printf("%lld\n",a[i]);
}
A segfault basically means you did something bad with pointers. This is probably a segfault:
char *c = NULL;
…
*c; // dereferencing a NULL pointer
Or this:
char *c = “Hello”;
…
c[10] = ‘z’; // out of bounds, or in this case, writing into read-only memory
Or maybe this:
char *c = new char[10];
…
delete [] c;
…
c[2] = ‘z’; // accessing freed memory
Same basic principle in each case - you’re doing something with memory that isn’t yours.
Adobe Systems is hiring Software Engineers
CTC:- 8-30 Lac, Exp:- 0-8 Years, Bangalore
Apply Here:- http://jobsiit.com/jobs/view/1876/Adobe-Systems/Software-Engineer
Why do I get SIGSEGV error for this code CodeChef: Practical coding for everyone
Please help, I haven’t used pointers or functions and it runs perfectly well on code blocks
#include<stdio.h>
int main()
{
int i,n,f=1,j=1;
scanf("%d",&n);
int a[10];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
f=1;j=1;
while(j<=a[i]){
f=f*j;
j++;
}
printf("%d\n",f);
}
return 0;
}
why am i getting a run time error here?
Can anyone tell me why i am getting run time error(sigsegv) for this
https://www.codechef.com/viewsolution/7491260
Problem: E1 Problem - CodeChef
Just check if you are accessing any element outside the declared array size,most common error might be in a loop.