Click here to Skip to main content
15,891,607 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDoes anyone know about "MSUIM.Msg.Private"? Pin
fitatc25-May-09 22:00
fitatc25-May-09 22:00 
QuestionVC++ 6.0 + Processor Pack + Service Pack 5 cause stack overflow ? Pin
felixfan81925-May-09 21:57
felixfan81925-May-09 21:57 
QuestionHow to handle time delays Pin
V K 225-May-09 20:32
V K 225-May-09 20:32 
AnswerRe: How to handle time delays Pin
CPallini25-May-09 20:45
mveCPallini25-May-09 20:45 
AnswerRe: How to handle time delays Pin
Rajesh R Subramanian25-May-09 20:53
professionalRajesh R Subramanian25-May-09 20:53 
GeneralRe: How to handle time delays Pin
V K 225-May-09 20:54
V K 225-May-09 20:54 
GeneralRe: How to handle time delays Pin
CPallini25-May-09 20:59
mveCPallini25-May-09 20:59 
QuestionHelp on dynamic memory allocation and deallocation Pin
pani6825-May-09 20:08
pani6825-May-09 20:08 
Hello!

I want to use dynamic memory allocation for multi-dimensional arrays. While allocating there is no problem. But how to deallocate the memory? If I use the Method-1 will it be okay or will it cause memory leak or run time error? Which of the two methods are technically correct?

int nVal,i;
int **pVal=NULL;

//	Allocating memory

pVal = new int * [5];

for(i=0;i<5;i++)
	pVal[i] = new int [3];


Deallocation Method - 1
//	Method - 1 (deallocate the main array only)

...

...


//	Deallocating memory

//	Deallocate memory of main array
delete [] pVal;


Deallocation Method - 2
//	Method - 2 (deallocate individual arrays, then the main array)
...

...


//	Deallocate memory of individual arrays

for(i=0;i<5;i++)
	delete [] pVal[i];


//	Deallocate memory of main array
delete [] pVal;


Any help in this matter will be highly appreciated. Thanks in advance.
AnswerRe: Help on dynamic memory allocation and deallocation Pin
«_Superman_»25-May-09 20:22
professional«_Superman_»25-May-09 20:22 
AnswerRe: Help on dynamic memory allocation and deallocation Pin
Cedric Moonen25-May-09 20:29
Cedric Moonen25-May-09 20:29 
AnswerRe: Help on dynamic memory allocation and deallocation Pin
Stuart Dootson25-May-09 23:08
professionalStuart Dootson25-May-09 23:08 
AnswerRe: Help on dynamic memory allocation and deallocation Pin
pani6826-May-09 2:15
pani6826-May-09 2:15 
QuestionHow do I convert .CPL to .MSC? Pin
Member 466633025-May-09 19:58
Member 466633025-May-09 19:58 
AnswerRe: How do I convert .CPL to .MSC? Pin
Stuart Dootson25-May-09 23:16
professionalStuart Dootson25-May-09 23:16 
GeneralRe: How do I convert .CPL to .MSC? Pin
Member 466633026-May-09 18:03
Member 466633026-May-09 18:03 
GeneralRe: How do I convert .CPL to .MSC? Pin
Stuart Dootson26-May-09 21:29
professionalStuart Dootson26-May-09 21:29 
GeneralRe: How do I convert .CPL to .MSC? Pin
Member 466633027-May-09 14:48
Member 466633027-May-09 14:48 
GeneralRe: How do I convert .CPL to .MSC? Pin
Stuart Dootson27-May-09 20:50
professionalStuart Dootson27-May-09 20:50 
GeneralRe: How do I convert .CPL to .MSC? Pin
Member 466633027-May-09 20:56
Member 466633027-May-09 20:56 
Question_variant_t Pin
vital_parsley200025-May-09 19:36
vital_parsley200025-May-09 19:36 
AnswerRe: _variant_t Pin
«_Superman_»25-May-09 19:42
professional«_Superman_»25-May-09 19:42 
GeneralRe: _variant_t Pin
vital_parsley200025-May-09 20:47
vital_parsley200025-May-09 20:47 
GeneralRe: _variant_t Pin
«_Superman_»25-May-09 21:51
professional«_Superman_»25-May-09 21:51 
GeneralRe: _variant_t Pin
vital_parsley200025-May-09 21:57
vital_parsley200025-May-09 21:57 
QuestionRe: _variant_t Pin
CPallini25-May-09 22:06
mveCPallini25-May-09 22:06 

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.