Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • i cannot change the header file because it is the requirements I have to follow. which is why fileName cannot be a char array, but a char pointer. and ReadFile() is called only once in the entire program. and fileName is only ever used in ReadFile(). Commented Oct 20, 2012 at 23:59
  • oh and fileName is not getting deleted for sure. because when I take delete []fileName; out of the destructor and put it at the end of ReadFile() after file.close() i don't get any memory leak msg. Commented Oct 21, 2012 at 0:01
  • @livelaughlove - you've just logically proved that your problem does not exist. So you have to figure out which of your premises is wrong. Sorry, but handwaving assertions won't get you any meaningful help. Post real code, the smallest example you can put together that compiles, runs, and demonstrates the problem. Commented Oct 21, 2012 at 0:02
  • the only code I didn't post is what I do with the file. but that has nothing to do with the fileName. the fileName is only used to store what the user inputs and use that to open the file. like i said the rest of the program works fine and I am just trying to get rid of memory leaks. when delete []fileName; is in destructor, I get a memory leak msg. when delete []fileName; is at the end of ReadFile() I get no memory leak msg. that is what I don't understand. Commented Oct 21, 2012 at 0:07