Thread: two dimensional array initialization

  1. #1
    Registered User
    Join Date
    Feb 2014
    Posts
    54

    two dimensional array initialization

    I have used following array initialization in my code.

    Code:
    static const int a[][] = { {2, -5, 7},
                                      {4, 8, -2},
                                      {7, 24, 78} };
    But it is giving following error during compilation.

    error: array type has incomplete element type

    I think we can omit the array size if we are initializing the array.
    Can you please tell me why it is giving the compilation error.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    only one (first) dimension size could be omitted
    6.5 — Multidimensional Arrays « Learn C++
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. initialization in multi dimensional arrays
    By narendrav in forum C Programming
    Replies: 41
    Last Post: 03-17-2014, 11:06 PM
  2. Replies: 12
    Last Post: 09-02-2013, 07:50 PM
  3. Replies: 4
    Last Post: 09-02-2013, 11:19 AM
  4. two dimensional array initialization
    By George2 in forum C Programming
    Replies: 3
    Last Post: 07-27-2007, 06:53 AM
  5. Two-Dimensional Array Initialization (please help)
    By pompey4life in forum C Programming
    Replies: 2
    Last Post: 10-17-2005, 07:09 PM

Tags for this Thread