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 3695470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:37:18+00:00 2026-05-19T04:37:18+00:00

I am making several calls to a function that initializes 2-d arrays of doubles.

  • 0

I am making several calls to a function that initializes 2-d arrays of doubles. The first three calls are successful, but the fourth call fails. Code is:

double **scmass;
double **scdv;
double **dvmatches;
double **zpp;

…

scmass = init_d2darr(numrow,numcol);
scdv = init_d2darr(numrow,numcol);
dvmatches = init_d2darr(numrow,numcol);
zpp = init_d2darr(numrow,numcol);

…

double ** init_d2darr(int isize, int jsize) {
int m,n;
printf("in array initialize 1\n");
printf("isize: %i\njsize: %i\n",isize,jsize);
/* how many rows */
double **arr = (double **)malloc(sizeof(double *) * isize);
printf("after row initialization\n");
if (arr == NULL) {
    printf("malloc failed for arr in init_d2darr.\n");
    return NULL;
}
else {
    /* now how many cols */
    for (m=0; m<=isize; m++) {
        arr[m] = (double *)malloc(sizeof(double) * jsize);
        if (arr[m] == NULL) {
            printf("malloc failed for arr[%d] in init_d2darr.\n",m);
            return NULL;
        }
        else {
            /* initialize all to zero */
            for (n=0; n<jsize; n++) {
                arr[m][n] = 0;
            }
        }
    }
}
printf("in array initialize 2\n");
return arr;

Output looks like:

in array initialize 1
isize: 20
jsize: 21
after row initialization
in array initialize 2
in array initialize 1
isize: 20
jsize: 21
after row initialization
in array initialize 2
in array initialize 1
isize: 20
jsize: 21

The program actually runs all the way through when in debug mode, however, when I make a release executable and attempt to run it, the program crashes and I get the error “A problem caused the program to stop working correctly. Please close the program.” I’m on windows vista with Visual C++ 2008 Express Edition. Could anyone give me any advice? Thanks!

Jade

Edit: the declaration of the function (in a header file) is

double ** init_d2darr(int isize, int jsize);
  • 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-19T04:37:19+00:00Added an answer on May 19, 2026 at 4:37 am

    In your outer for-loop:

    for (m=0; m <= isize; m++) 
    

    this should be:

    for (m=0; m < isize; m++) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand there are several factors involved when making db calls and internet, but
I am making several jQuery ajax calls within a loop. Each time one of
I'm developing a simple function that, making use of superagent module, query an API
I'm making several calls to BitmapFactory.decodeFile() and BitmapFactory.decodeResource() , and I'd like to specify
My coworker suggested making several of the Eclipse code-formatting and warning settings to be
The program I am making has several views in which the user is trying
I've got a table with several columns making up the primary key. The nature
I have several large CSS files and making a change can sometimes take a
I am making an android application which has a main activity and several other
My project uses several dll files with activex controls. Now I am making a

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.