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...


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);


}





Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here