-
file reading
To great C++ programmer.
If i want to read source file and write its contents to destination file. However, The program must check certain sentence first. This line can be anywhere in the file. It must have "tel" and "=".
Like this
File A
Tel = area code + number // Must check whether this line exist
703-461-****
703-461-**%%
What i am thinking is using getline()
//////////////////////////////////////////////////////////
string buffer;
while(getline(infile,buffer))//check line by line
//////////////////////////////////////////////////////////
How can i let the program check the sentence first?
-
Probably best to read every line into program one by one and search for the substring "Tel =" using one of several techniques depending what type of string you are using. Once you have found the desired substring you can do what you want--write next two lines to destination file, stop writing to destination file, display "Mary Had A Little Lamb" on the screen, whatever.