vendredi 4 décembre 2020

C++: Check if a file is running

very noob here. Basically what I wanna do is that as soon as I run my program, it opens a txt file. Then starts a while loop that only ends whenever I close the file.

I know this is definitely more complex to do, if possible, than what I wrote down here, but I hope to learn something new :)

#include <iostream>
#include <windows.h>
using namespace std;

main()
{
        system("test.txt"); //open my file

        while(ProcessIsRunning()) //???
        {
                cout << "Process is currently running...";
                Sleep(1000);
        }
        
        cout << "Process has stopped running"; //when I close my file, exits while and outputs this

}

Aucun commentaire:

Enregistrer un commentaire