Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Looks ok to my eyes.

Generates error C2078: too many initializers VS2008

C++
static DWORD 2DArray[5][4] =
{
    { 0 , 1 },  { 1 , 4 }, { 2 , 5 }, { 3 , 6 }, { 4 , 25 },
    { 0 , 2 },  { 1 , 9 }, { 2 , 10}, { 3 , 11}, { 4 , 26 },
    { 0 , 3 },  { 1 , 13}, { 2 , 14}, { 3 , 15}, { 4 , 23 },
	{ 0 , 4 },  { 1 , 17}, { 2 , 18}, { 3 , 19}, { 4 , 22 }
};


:Ron
Posted
Comments
CPallini 26-Jun-15 11:44am    
DWORD is 'double word', not 'two numbers'. :-)

That's because there are too many initializers :P


You are specifying the array as 5x4, yet you have initializers 20x2

Either use static DWORD 2DArray[20][2] = or change the initializer like so:

C++
static DWORD 2DArray[5][4] =
{
    { 0 , 1 , 2 , 3 }  
    { 1 , 1 , 2 , 3 } 
    { 2 , 1 , 2 , 3 }  
    { 3 , 1 , 2 , 3 } 
    { 4 , 1 , 2 , 3 } 
}


EDIT: Perhaps you meant:

C++
static DWORD 3DArray[4][5][2] =
{// there are 4 x 2DArray[5][2]
    {// there are 5 x Array[2]
       { 0 , 1 },  // this is an int[2]
       { 1 , 4 },  
       { 2 , 5 },   
       { 3 , 6 },   
       { 4 , 25 }
    },
    {
       { 0 , 2 },  { 1 , 9 }, { 2 , 10}, { 3 , 11}, { 4 , 26 }
    },
    {
       { 0 , 3 },  { 1 , 13}, { 2 , 14}, { 3 , 15}, { 4 , 23 }
    },
    {
       { 0 , 4 },  { 1 , 17}, { 2 , 18}, { 3 , 19}, { 4 , 22 }
    }
}


You don't need the first digit if these are the real numbers as they relate to the index anyway.

I would suggest:

C++
static DWORD 3DArray[4][5] =
{// there are 4 x 2DArray[5]
    {// there are 5 x int
        1, 4, 5, 6, 25 },
    { 2 , 9 , 10 , 11 , 26 },
    { 3 , 13 , 14 , 15 , 23 },
    { 4 , 17 , 18 , 19 , 22 }
}
 
Share this answer
 
v4
Comments
Ron Anders 26-Jun-15 10:00am    
Sorry, thats what happens when I start in before I am fully awake.

Thanks
Andy Lanng 26-Jun-15 10:01am    
;)
Sergey Alexandrovich Kryukov 26-Jun-15 11:12am    
5ed.
—SA
Andy Lanng 26-Jun-15 11:19am    
Thanks SA ^_^
"Praise from Caesar is praise indeed"
Don't give up, cheat on the compiler:
C++
struct DWORD
{
  int x,y;
};
static DWORD Array[5][4] =
{
 {  { 0 ,  1}, { 1 ,  4}, { 2 ,  5}, { 3 ,  6}, },
 {  { 4 , 25}, { 0 ,  2}, { 1 ,  9}, { 2 , 10}, },
 {  { 3 , 11}, { 4 , 26}, { 0 ,  3}, { 1 , 13}, },
 {  { 2 , 14}, { 3 , 15}, { 4 , 23}, { 0 ,  4}, },
 {  { 1 , 17}, { 2 , 18}, { 3 , 19}, { 4 , 22}, },
};


:omg:
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900