Here is my program for the problem AVION1 and it got SIGSEGV when submitted in C99 strict:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define MAX_LEN 10
//char line[MAX_LEN+1];
int main() {
bool found = false;
for (int i = 1; i <= 5; ++i) {
char line[MAX_LEN+1];
scanf("%s", line);
if (strstr(line, "FBI")) {
printf("%s%d", found ? " " : "", i);
found = true;
}
}
puts(found ? "" : "HE GOT AWAY!");
}
When I change the local var line to global, it got AC.
Please tell me why.