C++ Problem with atexit(); "void" incompatible with "void (__cdecl *)()"

  atexit, c++

I’m new here 🙂
I need help with my program please: i want delete all .txt files in program folder when it closes.
For deleting i use system("del /s *.txt"); but i want to do it when the program closes so i’ve made a void function

void deleteTxt() {
  system("del /s *.txt");
}

and in main i’ve set atexit(deleteTxt()); but appears the error: "void" incompatible with "void (__cdecl *)()"

what i can do?
Thanks and have a good day.

Source: Windows Questions C++

LEAVE A COMMENT