Runtime error

#include<stdio.h>
#include<string.h>
struct Hole
{
int a;
char w[100];
}b[40];
void main()
{
int t,j,i;
scanf("%d",&t);
if(t<41)
{
for(i=0;i<t;i++)
{
scanf("%s",b[i].w);
for(j=0;j<strlen(b[i].w);j++)
{
if(b[i].w[j]==‘A’||b[i].w[j]==‘D’||b[i].w[j]==‘Q’
||b[i].w[j]==‘R’||b[i].w[j]==‘O’||b[i].w[j]==‘P’)
b[i].a++;
else if(b[i].w[j]==‘B’)
b[i].a+=2;
else
continue;
}
}
for(i=0;i<t;i++)
{
printf("%d\n",b[i].a);
}
}
}

Please help me find the Runtime error.
TY

Possible because your code is allocating some amount of memory which exceeds the given permissible memory range. You have allocated the space of 40*(size of one struct node = 100 +4) i.e. 40*(104) bytes in advance. The problem can be solved by taking the input at run time and then calculating it. Why wasting so much of space?? This is the reason of SIGSEGV. Also, please always post ideone link or properly indented code. That becomes easy for people to understand and look. :slight_smile:

just add return 0 before your main function ends and replace void main() by int main(), you will get an AC! :slight_smile: