Click here to Skip to main content
15,921,113 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Need your suggestion !! Pin
CPallini30-Jan-08 23:49
mveCPallini30-Jan-08 23:49 
GeneralRe: Need your suggestion !! Pin
Rajesh R Subramanian31-Jan-08 2:23
professionalRajesh R Subramanian31-Jan-08 2:23 
Generalhelp me Pin
gentleguy30-Jan-08 20:02
gentleguy30-Jan-08 20:02 
GeneralRe: help me Pin
Cedric Moonen30-Jan-08 20:05
Cedric Moonen30-Jan-08 20:05 
GeneralRe: help me Pin
king'ori30-Jan-08 20:13
king'ori30-Jan-08 20:13 
GeneralRe: help me Pin
Hamid_RT30-Jan-08 21:37
Hamid_RT30-Jan-08 21:37 
GeneralRe: help me Pin
gentleguy30-Jan-08 22:05
gentleguy30-Jan-08 22:05 
GeneralRe: help me Pin
Iain Clarke, Warrior Programmer30-Jan-08 22:55
Iain Clarke, Warrior Programmer30-Jan-08 22:55 
li zhiyuan wrote:
how to create a 2D dynamic array?


Simple answer... You can't. Which is why you're getting an error.

Longer answer... You cheat. Create a one dimensional dynamic array. But make it an array of double *s, then create those arrays.

typedef double *pdouble;

// create a 2D virtual array
pdouble *c = new pdouble [N];
for (n = 0; n < N; n++)
    c [n] = new double [m];


....  ; do your processing code

// Tidy up 2D virtual array
for (n = 0; n < N; n++)
    delete [] c [n];
delete [] c;


Notice I'm using delete [] instead of delete. The [] means it will call the destructor for each member of the array(s). For simple types like double and double *, it makes no difference. But it makes no harm, and is a good habit to get into. Then you can make arrays of classes/structs that *could* have destructors, and you'll be thankful for your good habits.

I hope that helped,

Iain.

ps, In addition, please use the <pre> / </pre> keywords in your posts. And longer variables. They're hard to read now, and you're going to hate yourself in two years time.
GeneralRe: help me Pin
gentleguy30-Jan-08 23:18
gentleguy30-Jan-08 23:18 
GeneralRe: help me Pin
Iain Clarke, Warrior Programmer30-Jan-08 23:22
Iain Clarke, Warrior Programmer30-Jan-08 23:22 
GeneralRe: help me Pin
David Crow31-Jan-08 3:10
David Crow31-Jan-08 3:10 
Questioncan anybody help me out..... Pin
philiptabraham30-Jan-08 19:44
philiptabraham30-Jan-08 19:44 
AnswerRe: can anybody help me out..... Pin
Steve Echols30-Jan-08 19:49
Steve Echols30-Jan-08 19:49 
GeneralWindows Service (.Net) for C++ application Pin
CodingLover30-Jan-08 18:53
CodingLover30-Jan-08 18:53 
GeneralStretchBlt function Pin
rp_suman30-Jan-08 18:44
rp_suman30-Jan-08 18:44 
GeneralRe: StretchBlt function Pin
Steve Echols30-Jan-08 19:54
Steve Echols30-Jan-08 19:54 
QuestionHow can play .dat files with the help of MCIWnd? Pin
Le@rner30-Jan-08 18:43
Le@rner30-Jan-08 18:43 
AnswerRe: How can play .dat files with the help of MCIWnd? Pin
Hamid_RT30-Jan-08 19:32
Hamid_RT30-Jan-08 19:32 
GeneralRe: How can play .dat files with the help of MCIWnd? Pin
Le@rner30-Jan-08 20:16
Le@rner30-Jan-08 20:16 
GeneralRe: How can play .dat files with the help of MCIWnd? Pin
Hamid_RT30-Jan-08 21:33
Hamid_RT30-Jan-08 21:33 
GeneralNeed help using List Control Pin
SnaKeBeD30-Jan-08 18:12
SnaKeBeD30-Jan-08 18:12 
GeneralRe: Need help using List Control Pin
Hamid_RT30-Jan-08 19:35
Hamid_RT30-Jan-08 19:35 
GeneralRe: Need help using List Control Pin
David Crow31-Jan-08 3:16
David Crow31-Jan-08 3:16 
GeneralLinker Output .dll and .lib Pin
ForNow30-Jan-08 17:59
ForNow30-Jan-08 17:59 
AnswerRe: Linker Output .dll and .lib Pin
Rajkumar R30-Jan-08 21:17
Rajkumar R30-Jan-08 21:17 

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.