Day 27/100 100 Days of Code

Photo by RetroSupply on Unsplash

Day 27/100 100 Days of Code

Info Hunter

Today, I ran some tests to find bugs. One of the bugs I found was that the text file that saved content was being emptied as soon as a new thread started working on its operation. This happened because I never opened the content file in append mode, meaning each operation would clear the file before adding anything.

I added a conditional statement to clear the content file only at the beginning of the operation and then, each thread will open it in append mode to add any findings in the file.

if(hasStarted)
    {
        contentFile.open("../content/content.txt", std::ios::app);
    }else
    {
        contentFile.open("../content/content.txt");
        hasStarted = true;
    }

I added some std::cout statements in the application to examine the inputs and results of the operations.