|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
The Gentle Art of File Data Extraction
I'm trying to find and extract data from a file with C, but I can't seem to find a good way to do so. I almost thought I had it there with strncmp() for a while, but that road only led to dissapointment.
Here's what I'm trying to do: Given a file like this; --start of fake.db-- Harry$555-3489$Lake Worth Peter$555-8230$Paris Simone$555-3903$Kiev Fred$555-9308$Chile Gulliver$555-0376$Paris Stephanie$555-0903$Monterrey --end of fake.db-- I want to be able to input a location, a phone number, or a name and return the entire line for my parsing. Anyone have any ideas? Perhaps a new function to explore? |
|
#2
|
||||
|
||||
|
Ever thought of exploring the strstr() function
![]() |
|
#3
|
||||
|
||||
|
thanks... I looked up some info (http://www.opengroup.org/onlinepubs...xsh/strstr.html) on that function and I'm not sure I see how it can help me...
perhaps you have deeper examples of how this works? |
|
#4
|
||||
|
||||
|
Code:
if (strstr(searchstr, filestr) != null)
//this line contains the data
else
//this line does not contain the data
|
|
#5
|
|||
|
|||
|
I found a good utility for data extraction. Try this.
URL |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > The Gentle Art of File Data Extraction |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|