Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


A compiler gone bad....

This topic is 6416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!