Kifah Abbad wrote:
hi guys,
First thanks for the support in my last question posted here.
Now i have been trying today to read about finding a way to solve this
(simple?) problem....which is...i have a string lets say "Leila" from
user and i want to search a text file with a table of values "name of
girl" "hair color", so like this somehow:
Leila black
Sabrina blonde
Sheila black
.
.
etc...
Now i want to get the value of the "hair color" and do something with
it....printf-it or whatever...what is the most memory effective way to
do so?is it with awk and grep and stuff? or something else?
Thanks
PS: the question is more about IP adresses, but maybe girls and would
get thoughts more smooth :-D
If this file contains records (lines) of fixed length, you could
just position to a new record, read it in and process it.
For files containing variable length records, such as text files,
you will have to read in one record at a time. You will need to
determine what is in a record and how to separate fields within
the record.
The fundamental process is to read in a record and compare the
key field with a given key. If the keys match, process the
record; done. Otherwise read in the next record; repeat.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book