LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-21-2007, 03:49 AM   #1
raklo
Member
 
Registered: Apr 2006
Posts: 143

Rep: Reputation: 15
writing a c code for scanning files for certain phrases


hello all,
i wanna write a c code,that scans a large file for certain phrases.
ideally,code should get 2 files as input.one contains the phrases
and other the file that is to be scanned.

wot should the approach be like???
 
Old 06-21-2007, 03:52 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Slack, Debian, Mint, Puppy, Raspbian
Posts: 3,467

Rep: Reputation: 221Reputation: 221Reputation: 221
grep -f input.one file

 
Old 06-21-2007, 06:52 AM   #3
raklo
Member
 
Registered: Apr 2006
Posts: 143

Original Poster
Rep: Reputation: 15
thanx a lot,
actually i wanna write a code that can do that,which then i 'll need to modify
for some other purposes.
i went thru the source of grep ,but couldnt grasp much.

cud anyone tell ,wot apprch does that follow??
 
Old 06-21-2007, 12:47 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Your problem is classified as primarily a searching problem. As such, you will want to use an algorithm that is optimized for that task. Googling 'string search algorithm' will lead you to numerous resources for such algorithms. The requirements of your specific application should dictate which algorithm you choose. If you wish to make your string searcher into something more general (and at the same time more powerful), you may wish to look at lex & yacc (flex & bison in Gnu-speak) to create a more grep-like tool. I would consider this to be a different genre than string searching.

--- rod.

Last edited by theNbomr; 06-21-2007 at 12:51 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Code Craft: The Practice of Writing Excellent Code LXer Syndicated Linux News 0 01-09-2007 05:03 AM
LXer: Democratization, Writing and Writing Code LXer Syndicated Linux News 0 11-22-2006 06:03 AM
php code not writing or working? ati Programming 4 05-11-2006 08:51 AM
A simple question. turning off phrases. anton_w Slackware 3 09-21-2005 07:27 AM
Book about writing secure code Covel Linux - Security 1 06-12-2004 02:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration