help writing a grep program

Reply

Join Date: Nov 2004
Posts: 6
Reputation: kiki021600 is an unknown quantity at this point 
Solved Threads: 0
kiki021600's Avatar
kiki021600 kiki021600 is offline Offline
Newbie Poster

help writing a grep program

 
0
  #1
Nov 28th, 2004
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!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: help writing a grep program

 
0
  #2
Nov 28th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6
Reputation: kiki021600 is an unknown quantity at this point 
Solved Threads: 0
kiki021600's Avatar
kiki021600 kiki021600 is offline Offline
Newbie Poster

Re: help writing a grep program

 
0
  #3
Nov 28th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 68
Reputation: harshchandra is an unknown quantity at this point 
Solved Threads: 1
harshchandra harshchandra is offline Offline
Junior Poster in Training

Re: help writing a grep program

 
0
  #4
Nov 28th, 2004
i think u can easily convert "hello" to "HELLO" by using toupper() function
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: help writing a grep program

 
0
  #5
Nov 29th, 2004
char * strcasestr (const char *haystack, const char *needle)

This is like strstr, except that it ignores case in searching for the substring :lol:
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC