Hi Everyone
I have to write a grep program in C and I am not sure where to start. :?:
I need to use strstr() from the standard library, and get it to work; but I dont know how to do that.
And that's only half the program, the second part is "getting strstr() to do case-insensitive searches"... But the professor says it can't; "you know what happens when you know what verb you need, you know what you need it to do, but it isn't available?... you write it" I am not sure what that means and I have no clue what strstr() means! If someone could just help me get started i would really appreciate it. This is my first time taking programming and It is soooo much harder than I thought!
Thanks In Advance!

strstr is a standard function that searches for occurrances of one string inside another.
This is exactly what grep does at its most basic.
It can indeed not search case insensitive but with a little thinking you will be able to figure out how to use it anyway.
Hint: how do you turn "Hello" into "HELLO"?

Your professor seems like a wise man making that statement. He tells you to first think about how you'd solve the problem rather than sit down and start coding like a maniac.

strstr is a standard function that searches for occurrances of one string inside another.
This is exactly what grep does at its most basic.
It can indeed not search case insensitive but with a little thinking you will be able to figure out how to use it anyway.
Hint: how do you turn "Hello" into "HELLO"?

Your professor seems like a wise man making that statement. He tells you to first think about how you'd solve the problem rather than sit down and start coding like a maniac.

I dont know how to turn hello into HELLO!
I would like to sit down and code like a maniac, I understand whta to do but putting it in computer language is hard for me.

char * strcasestr (const char *haystack, const char *needle)

This is like strstr, except that it ignores case in searching for the substring :lol:

This article has been dead for over six months. Start a new discussion instead.