Thread: array dimension

  1. #1
    Registered User
    Join Date
    Oct 2003

    Thumbs down array dimension

    how can i make 400x400 dimension array. below is my code and the result is in one dimension(16000x1). i'm using C++ Builder.

    void __fastcall TForm1::Button1Click(TObject *Sender)
       int DataWidth = Image1->Picture->Width;
       int DataHeight = Image1->Picture->Height;
       for (int y=0;y<DataHeight;y++)
          for (int x=0;x<DataWidth;x++)
             Data[y][x] = (Byte)Image1->Canvas->Pixels[x][y];
        TStringList*show = new TStringList;
         for (int j=0;j<400;j++)
            for (int i=0;i<400;i++)
                 delete show;

  2. #2
    Registered User
    Join Date
    Mar 2002
    You need to declare Data somewhere, proably using the new operator, and then associate DataWidth and DataHeight with x and y. If you want to make Data local the function posted you can do it there, otherwise, you probably have a mainForm with WINMAIN and the main() function listed somewhere. You can put it in there and then pass Data to the functions that need to use it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating double dimension array.
    By apacz in forum C++ Programming
    Replies: 4
    Last Post: 05-23-2005, 12:39 PM
  2. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM
  3. 2 dimension string array
    By djarian in forum C Programming
    Replies: 4
    Last Post: 05-05-2003, 12:47 AM
  4. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 04:27 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM