I'm encountering an error when compiling mine application. It compiles fine but when I run it, I get two errors:
1) ConsoleApplication.exe has triggered a breakpoint.
2) I also get something about heap errors.
I've understood it had something to do with memory?
char *cstr = newchar[fileToDelete.length()];
It would not be large enough to hold whole fileToDelete string: you still need place for null terminator.
In your case there are no reasons to even have that temporary buffer (which you leak): as James2250 said, filestream constructor takes string as argument too (and you can use c_str if you are using decades old compiler) and you can safely pass c_str to remove too.