-
string search
I have a text file that I need to read.
The text file looks like this:
CARDATA
redcars.dat type_1.2-1 speed acceleration inertia
blackcars.txt type3.4.44-112 weight length wheelbase engine inertia speed
CONDITION
good fair poor
PRICE
0 25000.0 79000 125000.0 350000
My questions are:
1. How do I find a string within a string and store it ( in other words I don't want to store speed twice)?
2. The lines of text can be variable length so how can I process each line by reading it and finding the text I need? (ex: find the catagory CARDATA and ignore it, but I need redcars.dat and acceleration).
Thanks for your help!
-
There's a thread that deals with issues that are very much the same as yours. And it's not that far, either. Here's the link :
http://cboard.cprogramming.com/showthread.php?t=84529
-
also check out these links regarding string manipulation and reading a line from a file:
http://www.cplusplus.com/ref/cstring/
http://www.cplusplus.com/ref/cstdio/fgets.html
-
Thanks for the links but I still don't see how these answer the question of finding a string within a string. Can anyone provide an example (code) of searching for a string within a string?
I appreciate any help.
Thanks!
-
a string within a string is called a 'substring'. if you DID read the (1st) link i sent, youd have the answer.
-
-