Menu

Dynamic 2D array: how???

Johan Spee
2002-12-06
2012-09-26
  • Johan Spee

    Johan Spee - 2002-12-06

    Suppose I want to put a bitmap in a 2D array in memory. I determine the values for width and height in runtime (int w, h; ) and create the array..

           int (*bitmap)[h];
           bitmap= new int[w][h];

    then I can, for instance, get R, G or B values and put them in the array.

    This works fine With GCC, but Borland 5.5 gives an error: it refuses the h. If I put a number there, like

           int (*bitmap)[123];
           bitmap= new int[w][123];

    BCC compiles without objections. But since the dimensions of the bitmap are determined in runtime that is not an option.

    What's going on here? Is my code ok or isn't it?

    Johan

     
    • Johan Spee

      Johan Spee - 2002-12-06

      NO USER QUESTIONS HERE...

      Sorry. That wasn't clear to me. I've moved my question to the Users forum.

      This is confusing... questions like this appear in all 3 forums.

      Johan

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.