943,946 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 10524
  • C RSS
Nov 28th, 2004
0

help writing a grep program

Expand Post »
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!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kiki021600 is offline Offline
6 posts
since Nov 2004
Nov 28th, 2004
0

Re: help writing a grep program

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.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Nov 28th, 2004
0

Re: help writing a grep program

Quote originally posted by jwenting ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kiki021600 is offline Offline
6 posts
since Nov 2004
Nov 28th, 2004
0

Re: help writing a grep program

i think u can easily convert "hello" to "HELLO" by using toupper() function
Reputation Points: 7
Solved Threads: 1
Junior Poster in Training
harshchandra is offline Offline
68 posts
since Nov 2004
Nov 29th, 2004
0

Re: help writing a grep program

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

This is like strstr, except that it ignores case in searching for the substring :lol:
Reputation Points: 17
Solved Threads: 9
Posting Whiz in Training
frrossk is offline Offline
220 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: How to share memory between applications?
Next Thread in C Forum Timeline: List <char *> Problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC