Click here to Skip to main content
15,906,625 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTotally confused with memory alocation for '_get_pgmptr' function [modified] Pin
Hamed Musavi25-Jun-07 21:30
Hamed Musavi25-Jun-07 21:30 
Problem solved. Thanks.Rose | [Rose]

I need to use this function in c++ console app, and the documentation says:
errno_t <code>_get_pgmptr</code>( char **pValue );

pValue
A pointer to a string to be filled with ...

So I did this:
	char *path = new char[MAX_PATH+1];
	memset(path, NULL, MAX_PATH + 1);

	<code>_get_pgmptr</code>(&path);
...
        delete[] path;

But the call to the function, changes the address of the pointer(path) and calling the delete will fail.
I thought first that perhaps, I don't need to allocate any memory and the function (oddly) allocates it automatically and sends me the address but this is not the case either. Can anyone tell me what's wrong with this?

-- modified at 8:18 Tuesday 26th June, 2007
AnswerRe: Totally confused with memory alocation for '_get_pgmptr' function Pin
Rajkumar R25-Jun-07 21:58
Rajkumar R25-Jun-07 21:58 
GeneralRe: Totally confused with memory alocation for '_get_pgmptr' function Pin
Hamed Musavi25-Jun-07 22:16
Hamed Musavi25-Jun-07 22:16 
AnswerRe: Totally confused with memory alocation for '_get_pgmptr' function Pin
KaЯl25-Jun-07 22:48
KaЯl25-Jun-07 22:48 
GeneralRe: Totally confused with memory alocation for '_get_pgmptr' function Pin
Hamed Musavi26-Jun-07 2:19
Hamed Musavi26-Jun-07 2:19 
GeneralRe: Totally confused with memory alocation for '_get_pgmptr' function Pin
KaЯl26-Jun-07 2:39
KaЯl26-Jun-07 2:39 
QuestionWhat is the error in this code fragment Pin
xbiju25-Jun-07 21:16
xbiju25-Jun-07 21:16 
AnswerRe: What is the error in this code fragment Pin
Hamed Musavi25-Jun-07 21:33
Hamed Musavi25-Jun-07 21:33 
AnswerRe: What is the error in this code fragment Pin
Hamid_RT25-Jun-07 22:28
Hamid_RT25-Jun-07 22:28 
AnswerRe: What is the error in this code fragment Pin
Mark Salsbery26-Jun-07 7:08
Mark Salsbery26-Jun-07 7:08 
QuestionTab Order Pin
_anil_25-Jun-07 20:37
_anil_25-Jun-07 20:37 
AnswerRe: Tab Order Pin
Hamed Musavi25-Jun-07 21:54
Hamed Musavi25-Jun-07 21:54 
GeneralRe: Tab Order Pin
Hamid_RT25-Jun-07 22:32
Hamid_RT25-Jun-07 22:32 
GeneralRe: Tab Order Pin
Hamed Musavi25-Jun-07 22:41
Hamed Musavi25-Jun-07 22:41 
AnswerRe: Tab Order Pin
Hamid_RT25-Jun-07 22:21
Hamid_RT25-Jun-07 22:21 
GeneralRe: Tab Order Pin
_anil_25-Jun-07 23:19
_anil_25-Jun-07 23:19 
QuestionResizing list control with splitter and window Pin
neha.agarwal2725-Jun-07 20:20
neha.agarwal2725-Jun-07 20:20 
AnswerRe: Resizing list control with splitter and window Pin
_anil_25-Jun-07 20:42
_anil_25-Jun-07 20:42 
GeneralRe: Resizing list control with splitter and window Pin
neha.agarwal2725-Jun-07 21:08
neha.agarwal2725-Jun-07 21:08 
QuestionRe: Resizing list control with splitter and window Pin
Rajkumar R25-Jun-07 21:29
Rajkumar R25-Jun-07 21:29 
GeneralRe: Resizing list control with splitter and window Pin
_anil_25-Jun-07 21:56
_anil_25-Jun-07 21:56 
Questionhow to split a dialog box? Pin
vikramkarthik25-Jun-07 18:52
vikramkarthik25-Jun-07 18:52 
QuestionRe: how to split a dialog box? Pin
Perspx25-Jun-07 19:57
Perspx25-Jun-07 19:57 
AnswerRe: how to split a dialog box? Pin
Hamid_RT25-Jun-07 22:36
Hamid_RT25-Jun-07 22:36 
QuestionDeclare string array in heap Pin
Aqueel25-Jun-07 18:05
Aqueel25-Jun-07 18:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.