array dimension

This is a discussion on array dimension within the C++ Programming forums, part of the General Programming Boards category; how can i make 400x400 dimension array. below is my code and the result is in one dimension(16000x1). i'm using ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    8

    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.

    Code:
    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++)
                  {
                   show->Add(AnsiString(Data[i][j]));
                   }
                   show->SaveToFile("Luthor.dat");
                 delete show;
    }

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    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, 01: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, 01:47 AM
  4. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 05:27 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 09:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21