Computer Science
For each of the code snippet given below, identify the error and then write code after fixing the error.
Given code is the simulation of grep -v command. -v prints all lines that do not match a specific
pattern.
void grep_inverse(char *filename, char *str)
{
FILE *fp;
char buf[buff_size];
fp = fopen(filename, "r");
if(!fp) {
perror(filename);
}
else {
while (fgets(buf, buff_size, fp) != NULL) {
if ((strstr (buf, str)) != NULL)
printf("%s", buf);
fclose(fp);
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here