This topic is now archived and is closed to further replies.

Modifying a HTML-file via c++

This topic is 5381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! I''ve got a HTML-file with severeal keywords, like "the_time" or sth like that. My program should find these and replace them with a value, for example "3:00". can you teach me how to do this? thx zhiC

Share this post

Link to post
Share on other sites
There are a lot of good algorithms to do what you would want. One of the best (in the sense of an optimized algorithm) would certainly be Boyer-Moore (at least i think so).

But i think that for you, the time it takes doesn''t really matter because it''s probably not for a real-time application. I would then use the easiest way to do it:

Let M be your pattern (word ur looking for)
Start at the beginning of the file
While there still is something in the file
Check if your word is there,
if it is do what you want
Go to the next caracter
End while

The easiest way to do it is to read the whole file in a buffer, work on your buffer and then rewrite the file with the buffer. If you need help with that then just ask, otherwise I leave you the pleasure of doing it =>

Share this post

Link to post
Share on other sites