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

  • SEARCH
  • Home
  • 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 7187515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:51:47+00:00 2026-05-28T18:51:47+00:00

I have two questions regarding the multidimensional arrays. I declared a 3D array using

  • 0

I have two questions regarding the multidimensional arrays. I declared a 3D array using two stars but when I try to access the elements I get a used-without-initializing error.

unsigned **(test[10]);
**(test[0]) = 5;

Howcome I get that error while when I use the following code, I don’t get an error – What’s the difference?

unsigned test3[10][10][10];
**(test3[0]) = 5;

My second question is this: I’m trying to port a piece of code that was written for Unix to Windows. One of the lines is this:

unsigned **(precomputedHashesOfULSHs[nnStruct->nHFTuples]);

*nHFTuples is of type int but it’s not a constant, and this the error that I’m getting;

error C2057: expected constant expression

Is it possible that I’m getting this error because I’m running it on Windows not Unix? – and how would I solve this problem? I can’t make nHFTuples a constant because the user will need to provide the value for it!

  • 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-28T18:51:48+00:00Added an answer on May 28, 2026 at 6:51 pm

    In the first one, you didn’t declare a 3D array, you declared an array of 10 pointers to pointers to unsigned ints. When you dereference it, you’re dereferencing a garbage pointer.

    In the second one, you declared the array correctly but you’re using it wrong. Arrays are not pointers and you don’t dereference them.

    Do this:

    unsigned test3[10][10][10];
    test3[0][0][0] = 5;
    

    To answer your second question, you have to use a number that can be known at compile time as the size of an array. GCC has a nonstandard extension that allows you to do that, but it’s not portable and not part of the standard (though C99 introduced them). To fix it, you’ll have to use malloc and free:

    int i, j, k;
    
    unsigned*** precomputedHashOfULSHs = malloc(nnStruct->nHFTuples * sizeof(unsigned));
    
    for (i = 0; i < firstDimensionLength; ++i) {
        precomputedHashOfULSHs[i] = malloc(sizeOfFirstDimension * sizeof(unsigned));
    
        for (j = 0; j < secondDimensionLength; ++j) {
            precomputedHashOfULSHs[i][j] = malloc(sizeOfSecondDimension * sizeof(unsigned));
    
            for (k = 0; k < sizeOfSecondDimension; ++k)
                precomputedHashOfULSHs[i][j][k] = malloc(sizeof(unsigned));
        }
    }
    
    // then when you're done...
    
    for (i = 0; i < firstDimensionLength; ++i) {
        for (j = 0; j < secondDimensionLength; ++j) {
            for (k = 0; k < sizeOfSecondDimension; ++k)
                free(precomputedHashOfULSHs[i][j][k]);
    
            free(precomputedHashOfULSHs[i][j]);
        }
    
        free(precomputedHashOfULSHs[i]);
    }
    
    free(precomputedHashOfULSHs);
    

    (Pardon me if that allocation/deallocation code is wrong, it’s late :))

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I actually have two questions regarding the same problem but I think it is
I have two questions regarding jsTree: I am generating a jsTree using JSON with
I have two questions regarding a login form I'm styling. I am using onfocus
I have two questions regarding array: First one is regarding following code: int a[30];
I have two questions regarding built-in search feature of JqGrid. How to get all
I have two questions regarding to the positioning of a mpl window (using WXAgg
I have two questions regarding RewriteRule, but they're both closely related so I hope
I actually have two questions regarding exception/error handling in the iPhone app that I
I have two questions: 1) How can I make an array which points to
I have two questions. Do realloc() and memcpy() copy the entries in an array

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.