|
Right away you are setting envVar to an address of memory loaned to you by malloc. Right after that you are setting it to an address given to you by 'getenv'. You have lost the address given to you by malloc, thus you will not be able to free it without barfing in your own shirt pocket. I would suggest that you learn, first, about pointers, and secondly, about malloc/free and its requirements. Actually, since this is C++, you should shelve malloc/free in favor of new/delete.
|