I was getting Segmentation Fault (core dump) error when I run the code. After using some printf statement I found out that there is an error in strcmp part, maybe it's because comparing a char with a string? How do I fix this?
// this function checks if the file contains the *string
bool checkIfMatch(char *string, FILE *file) {
while (true) {
char buff[1024];
fgets(buff, sizeof buff, file);
if (buff == NULL)
break;
char *substring=strstr(buff, string);
if ((strcmp(buff, substring)) == 0)
return true;
}
return false;
}