Ok I know the basics of ofstream and ifstream but it seems as if every tutorial on it leaves this out. How do I delete files in c++ console app. Reason? I want to use a temporary file in my app for transferring betting two programs that open and to delete the file when done. Everything but that is done.

Recommended Answers

All 2 Replies

Your code should look something like this:

#include <cstdlib>
#include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, char *argv[])
{
    if( remove("Your File") != 0 )
       perror("File Deletion Failed");
    else
       puts("File Deletion Completed");
  return 0;
}
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hope this helps!

-Chris

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.