This is not a homework problem. This is a sample test problem and I wanted to know how to do it. It would be great if someone can help me. The question is:
Write a program, similar to grep, using regcomp(3C) and regexec(3C) to search for a regular expression pattern in standard input. Program synopsis:
Simple search for regular expression pattern in standard input.
0 One or more matches were found
1 No matches were found
2 Syntax errors or inaccessible files (even if matches were found)
Use regcomp flags: REG_NEWLINE | REG_NOSUB
Use a function in the form:
void regex_search( regex_t *preg, FILE *fp)
to perform the search. This function will be invoked from the main program as:
regex_search( ®, stdin);
I did not undertsnd how to do it as I am not very familiar with C. I am from an IC design background. It would be a great help for my exam preparations, if somebody can help me with this.
Thankyou very much.