Hello, new here and new to C++. I know a little about PHP, which I see is similar to C++ in some ways.

The project I'm working on is a program to open a file and remove certain lines of text and then save the revised file. I know how I'd do this in PHP, but from what I see C++ is much more powerful and I'm not yet familiar with the built in functions.

The knowns in the text files are the start of each new paragraph, and the start of each section to be removed.

The twist is that the section to be removed traverses many lines of the file.


$startofparagraph = xyz123;
$startofbadtext = 987654321;

file to be parsed:

xyz123 blah blah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blah. lah blah blah blahlah blah blah blahlah blah blah blah. lah blah blah blah. lah blah blah blahlah blah blah blahlah blah blah blah. 987654321 uuuu u u uu u u uuu uuuuuuuasd lakj laksdjf la alsdkjf ads flaksd lkfja sdlkjalsdk falskdj fla lkaj sldkfj als al lkajsd lfjka lskdj fla skldjfasd alkjdlakdjfalk l alksdj lfaksd fa lkj
xyz123 blah blah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blah. lah blah blah blahlah b 987654321 uuua uaus dlaksjd faa la;kjd flkajsd alk alsdk falksd fjlaksd jfasd falsdkfjals dfjka sdfasldkfj alksdjf asd ;lakj dslfkjasldjf aslkddjf alkaj f

(and so on... some files are large)


In PHP I'd create a variable that would contain the existing file text.

Then I'd use PHP's built in functions to look for the start of the first 'badtext' and get that position in the string. Then I'd get the position of the start of the next paragraph. I'd then use a function to strip out all text between the two integers. This would be repeated till I reached the end of the string.

With PHP being a simpler language, will doing the same in C++ be fairly involved?

Is there a function to strip text with a starting and ending position paremeter (for example, strip(33, 55) where 33 is start and 55 is end)?

Or will I be able to approach the project in the same way I might do it in PHP (store file contents in a string and go from there)?

Thanks for any preliminary pointers.