LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 04-02-2009, 01:49 AM   #1
vigneshinbox
LQ Newbie
 
Registered: Mar 2009
Posts: 19

Rep: Reputation: 0
how to retrieve some specific set of lines from a file and store it in a char buffer.


Plz tel me how to retrieve some specific set of lines from a file and store it in a char buffer.I am seperating each record by ":"

Code:
22:abc:4
hardware:cd:xyz:2
hardware:eth:abc:6
hardware:mouse:xyz:3
hardware:ram:xyz:1

23:cde:3
hardware:cd:xyz:2
hardware:eth:abc:6
hardware:ram:xyz:1

25:efg:2
hardware:cd:xyz:2
hardware:eth:abc:6
plz tel me how to retrieve

23:cde:3
hardware:cd:xyz:2
hardware:eth:abc:6
hardware:ram:xyz:1


from the file and store it in a buffer using C.Kindly help me in this
 
Old 04-02-2009, 01:58 AM   #2
vkmgeek
Member
 
Registered: Feb 2006
Location: Ahmedabad
Distribution: rhel5
Posts: 185
Blog Entries: 2

Rep: Reputation: 31
If you want to do it in C... There is no option other than writing a prog which does file operation like fopen and then fread...
Then you compare a string which you want, starting from that offset, store it in buff
 
Old 04-02-2009, 02:05 AM   #3
vigneshinbox
LQ Newbie
 
Registered: Mar 2009
Posts: 19

Original Poster
Rep: Reputation: 0
hey thanx for ur kind response dude.My question may be so stupid,but still... even when i tried
for the solution in net i came across the word OFFSET.what it is exactly?? and can u tell me which function should i use to traverse the file and compare it.
 
Old 04-02-2009, 02:16 AM   #4
vigneshinbox
LQ Newbie
 
Registered: Mar 2009
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by vkmgeek View Post
If you want to do it in C... There is no option other than writing a prog which does file operation like fopen and then fread...
Then you compare a string which you want, starting from that offset, store it in buff
Hey thanx for ur kind response dude.My question may be so stupid,but still... even when i tried
for the solution in net i came across the word OFFSET.what it is exactly?? and can u tell me which function should i use to traverse the file and compare it.
 
  


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
Substitute specific lines with lines from another file rahmathullakm Programming 4 01-10-2009 06:47 AM
[emacs] bookmark-set: Buffer not visiting a file or directory ypy13 Linux - Newbie 3 01-01-2009 09:04 PM
Delete specific lines of a file beginning with a certain letter docaia Programming 4 08-25-2008 12:04 AM
C: convert char buffer received from socket to host endianess buffer kpachopoulos Programming 3 06-07-2007 06:06 PM
Read specific lines from a text file chobin Programming 8 06-14-2006 12:14 PM


All times are GMT -5. The time now is 08:59 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration