I am currently doing a HTML log of daily transactions of an e-commerce website. I have to add transactions as a row to a table. Now I am stuck on how I do insert into the middle of the log file, just before the the closing </table></html> tag.
I was thinking of truncating the file to remove the closing tags, then continue to append to it. But there isn't any function that gives me back the size of a string, so I don't know the amount of offset for ftruncate().
PS. I know that actually without the closing tags, the html file will still show, but the perfectionist in me won't give up.