Why is my program causing SIGABRT error?
SIGABRT errors are caused by your program aborting due to a fatal error. In C++, this is normally due to an assert statement in C++ not returning true, but some STL elements can generate this if they try to store too much memory.
scanf( “%d”, &*( hill + i ) );
This line is wrong in your source code. You are deferencing then asking for address, you should write either (hill+i) or &hill[i]. No need for * operator.
https://www.codechef.com/viewsolution/11160529
why do i get SIGABART here ? the code works really fine when executed on other C IDEs.
CodeChef: Practical coding for everyone Why SIGABRT error here? It works fine on GeeksforGeeks IDE.
int* ans = new int[t]; should be written after cin>>t;
scanf("%d",&A[length]);
This line is the problem. The address of pointer A is being tried over here.
You’re using uninitialized variable to calloc
The variable a
points to a single uint
with value N
, not an array of N
uint
s If you want the latter, declare it as
a=new uint[N];
or, even better, just use a std::vector
and avoid the whole mess
why do i get sigabrt here
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
lli n,x;
cin>>n;
string a="010",b="101",s,temp;
for(x=0;x<n;x++){
lli p=0,i;
cin>>s;
for(i=0;i<s.length()-2;i++){
temp=s[i];
temp+=s[i+1];
temp+=s[i+2];
if(temp==a || temp==b){
cout<<"Good\n";
p=1;
break;
}
temp.clear();
}
if(p==0){
cout<<"Bad\n";
}
p=0;
}
return 0;
}
For now, you should probably be more concerned about why it’s giving the wrong answer for the Example Input (there’s little point in submitting a solution until - at minimum - it gives the correct answer for all provided examples).
Who knows? While debugging that, you may or may not find your answer
Not sure if this is a valid testcase (seems to meet the Constraints, at least), but consider the test input:
1
5 5
1 1 1 1 1