Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 973517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:17:29+00:00 2026-05-16T03:17:29+00:00

I just build my fist LED cube and want to expand the test code

  • 0

I just build my fist LED cube and want to expand the test code a bit. To address each LED of my 3x3x3 cube I want to use a corresponding three-dimensional array, but I got errors on its initialization.

Here’s what I did:

int cube_matrix[3][3][3] =
{
    { {0}, {0}, {0} },
    { {0}, {0}, {0} },
    { {0}, {0}, {0} }
},
{
    { {0}, {0}, {0} },
    { {0}, {0}, {0} },
    { {0}, {0}, {0} }
},
{
    { {0}, {0}, {0} },
    { {0}, {0}, {0} },
    { {0}, {0}, {0} }
};

Here’s the error I get:

error: expected unqualified-id before ‘{‘ token

I could use a for loop to initialize my array and get things done but my initialization seems correct to me, and I want to know what I did wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:17:29+00:00Added an answer on May 16, 2026 at 3:17 am

    If you’re really aiming for allocating the whole thing with zeros, you could use a simplified initializer:

    int cube_matrix[3][3][3] = {0};
    

    If you’d like more than zeros in there, you can do that too:

    #include <stdio.h>
    
    int main(int argc, char* argv[]) {
    
        int cube_matrix[3][3][3] = {1, 2, 3, 4, 5};
        int i, j, k;
    
        for (i=0; i<3; i++)
                for (j=0; j<3; j++)
                        for (k=0; k<3; k++)
                                printf("%i %i %i: %i\n", i, j, k, cube_matrix[i][j][k]);
    
        return 0;
    }
    

    With output that looks like this:

    $ ./a.out
    0 0 0: 1
    0 0 1: 2
    0 0 2: 3
    0 1 0: 4
    0 1 1: 5
    0 1 2: 0
    0 2 0: 0
    0 2 1: 0
    0 2 2: 0
    1 0 0: 0
    1 0 1: 0
    1 0 2: 0
    1 1 0: 0
    1 1 1: 0
    1 1 2: 0
    1 2 0: 0
    1 2 1: 0
    1 2 2: 0
    2 0 0: 0
    2 0 1: 0
    2 0 2: 0
    2 1 0: 0
    2 1 1: 0
    2 1 2: 0
    2 2 0: 0
    2 2 1: 0
    2 2 2: 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just build a sample application to test out google app engine and google
Can I just build html email as usually we build html pages? I want
I've been playing with Grails for few months and I've just build my first
i'm new to asp.net mvc.. so basically i just build up a two page
This build warning just started showing up. I'm building for 3.1.3. Not sure what
So I just trying to build a library using the NDK. I believe that
i'm now in java and eclipse, i just tried to build a simple calculator,
I just started trying to build simple GUIs because I've always used command-line script
Just wondering is it possible to build CLI app that can be run from
Just thinking about the best way to build an Order form that would (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.