Computing.Net > Forums > Programming > Too many initializers

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Too many initializers

Reply to Message Icon

Name: JackDuece
Date: October 6, 2005 at 20:36:13 Pacific
OS: Windows XP home 5.1 build
CPU/Ram: 512
Comment:

Im using Visual studio .net 2003 and im working with VC++. This line keeps telling me i have 'too many initializers'
char Deck[2][52] = {"CA","C2","C3","C4","C5","C6","C7", "C8","C9","C0","CJ","CQ","CK",
"DA","D2","D3","D4","D5","D6","D7",
"D8","D9","D0","DJ","DQ","DK",
"HA","H2","H3","H4","H5","H6","H7",
"H8","H9","H0","HJ","HQ","HK",
"SA","S2","S3","S4","S5","S6","S7",
"S8","S9","S0","SJ","SQ","SK"};

If I switch [2][52] to [52][2] i get out of bounds errors
What am I doing wrong?



Sponsored Link
Ads by Google

Response Number 1
Name: jlyon
Date: October 9, 2005 at 08:48:38 Pacific
Reply:

Just loop to initialize:

char Deck[2][52];

char DeckInit[52] = {"CA","C2","C3","C4","C5","C6","C7", "C8","C9","C0","CJ","CQ","CK",
"DA","D2","D3","D4","D5","D6","D7",
"D8","D9","D0","DJ","DQ","DK",
"HA","H2","H3","H4","H5","H6","H7",
"H8","H9","H0","HJ","HQ","HK",
"SA","S2","S3","S4","S5","S6","S7",
"S8","S9","S0","SJ","SQ","SK"};

========================

for(int i = 0; i < 1; ++i )
{
for(int j = 0; j < 52; ++j )
{
Deck[i][j]=DeckInit[j];
}
}

==================

That should accomplish the initialize, maybe not as pretty, but should work.

--j

This is my signature.


0

Response Number 2
Name: jlyon
Date: October 9, 2005 at 08:51:55 Pacific
Reply:

Oops,
first for should read: for(int i = 0; i < 2; ++i )

--j

P.S. Another thing I notice is that I don't think those are char values, If I'm not mistaken a char must be a single character like so 'a', 'b', 'c', '1', '2', '3', etc...


This is my signature.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Too many initializers

Factorial in Pascal www.computing.net/answers/programming/factorial-in-pascal/5692.html

Winamp - File size OK - Bitrate = 0 www.computing.net/answers/programming/winamp-file-size-ok-bitrate-0/9362.html

A fun project for software engineer www.computing.net/answers/programming/a-fun-project-for-software-engineer/9389.html