Quote Originally Posted by shadolink View Post
other posts talk about the fopen function and don't really give any solutions to this
There are no "solutions" you just can look up on google. Did you really expect to write a program and not ever need to debug it? You need to debug your program -- that is how you find the solution.

Second, the code is not C++, at least not traditional C++ that relates to this forum. You are using Managed C++, and this is not the correct forum. This forum is for traditional/ANSI C++ using the Visual C++ compiler and libraries associated with Visual C++ such as MFC. There is a separate forum for Managed C++ questions.
the var that has the file path is a char* and has been converted from a system::string^
There is no such thing as "system::string^" in this forum, again, go to the Managed C++ forum.
Code:
    pile.open(ConvertString(poo),ifstream::in)
//...
        int length = cnv->Length;
        char *out = new char[length+1];
        for(int i = 0;i < length;i++){
         out[i] = (char) cnv[i];
		 out[length] = '\0';
		}
	  return out;
This code, if it is to be looked at in terms of traditional C++, leaks memory, unless "open" somehow retrieves the pointer passed in and issues a "delete[]" somewhere. My bet is that it doesn't.

How are you going to call "delete[]" for the memory you allocated with "new[]"? When you call pile.open(), that pointer to the memory you allocated is gone and can never be retrieved, thus a memory leak.

Regards,

Paul McKenzie