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");
       puts("File Deletion Completed");
  return 0;
    return EXIT_SUCCESS;

Hope this helps!


Be a part of the DaniWeb community

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