I'm working on a simple lex program for class, and in it I'm creating a very rudimentary symbol table, just an array of strings with a linear scan for search. I've declared it as:
char* identifiers[100];
And I'm using it like so:
found = false;
for (i = 0; i < seen_identifiers; i++) {
if (!strcmp(identifiers[i], yytext)) {
printf("Identifier \"%s\" already in symbol table", yytext);
found = true;
break;
}
}
if (!found) {
printf("identifier: %s\n", yytext);
seen_identifiers++;
identifiers[seen_identifiers] = yytext;
}
However I consistently get a segfault at the strcmp call. I'm sure I've screwed up something super simple.