I'm trying to create a simple little program that will accept arguments of files (i.e. file1 and file2), and look for occurrences of the "match" string in the included arg files. Then I want to print out the whole line where the match is found preceded by the number of the line. In other words, I want to find "is" in my file args, and have it print "2: block is enough", 2 being the line number, and "block is enough" being the line where "is" is found. I want to use strstr and was thinking that I could use this to do so:
char *strstr(const char *haystack, const char *needle);
I want this to return NULL if the needle string is not found in the haystack string and otherwise return the pointer to where the needle is returned.
I was hoping someone could help me find a way to implement it as I want. All I really need is a small chunk of code in my main to do this, and I'll be able to continue with my program from there. Any help/ideas!!??
Thanks in advance!