LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 12: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, 12: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, 01: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, 01: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



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

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

All times are GMT -5. The time now is 09:22 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
Open Source Consulting | Domain Registration