Advertisement

A compiler gone bad....

Started by April 26, 2001 03:24 PM
1 comment, last by origil 23 years, 9 months ago
So I''ll simply begin with this concept:
It''s not my mistake, it''s my compiler which doesn''t accept it... and such a perfectionist snob he is... So I would like some people to help me with overcoming my problem, not talking about my temporary insanity, talking about why my compiler doesn''t like me having a pointer to a 2D array. Ok, now seriously, don''t want to waste your time. [Too late though].
char * *p = new char[20][30];
I realize the ''p'' should be declared differently than as I have declared above, but how?
I didn''t really get the concept of pointers to 2 dimensional arrays.
Any help would be appreciated.
The Department of Next Life - Get your Next-Life Insurance here!
Actually it is your mistake.

Your compiler expected something like this
  char **p;p = new char*[width];for(int i=0;i<width;i++)       p[i] = new char[height];  


But you gave him something else. Declaring a 2d array like you did is ok for static arrays, but doesn''t work for dynamic arrays.

If you look at the code I gave, the first new creates an array of char pointers, then for each pointer it creates an array of chars.
Advertisement
Thanks a lot.
I still think my compiler should do what I mean and not what I type but that''s the problem with compilers today

This topic is closed to new replies.

Advertisement