0

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.

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by NetJunkie
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.