searching a user entered string in a text file using File Operations

Reply

Join Date: Dec 2008
Posts: 8
Reputation: anu123d is an unknown quantity at this point 
Solved Threads: 0
anu123d anu123d is offline Offline
Newbie Poster

searching a user entered string in a text file using File Operations

 
0
  #1
Jan 29th, 2009
Greetings,

how can i write a search program to search a user entered string saved in an array, in a text file using File Operations in C. Specially using fseek() function.

Plz reply,
Thanks in advance..!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,624
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 714
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: searching a user entered string in a text file using File Operations

 
0
  #2
Jan 29th, 2009
You don't need fseek to do this, just read the file sequentially using (for example) fgets and look for the substring using strstr. Very simple.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: anu123d is an unknown quantity at this point 
Solved Threads: 0
anu123d anu123d is offline Offline
Newbie Poster

Re: searching a user entered string in a text file using File Operations

 
0
  #3
Jan 29th, 2009
yes, i was doing that. i searched for the string using strstr function. but when i tried to print from the position just after the last character of the searched string, by using a pointer, sumthing went wrong with the logic.
Is there any other way to do this ?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,624
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 714
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: searching a user entered string in a text file using File Operations

 
0
  #4
Jan 29th, 2009
>sumthing went wrong with the logic.
Then you should fix your logic, not start over from scratch. Clearly the problem isn't with the solution, it's with how you implemented the solution.
Last edited by Narue; Jan 29th, 2009 at 11:18 am.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC