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'm making several calls to BitmapFactory.decodeFile() and BitmapFactory.decodeResource() , and I'd like to specify
I'm currently working on a site that makes several calls to big name online
My coworker suggested making several of the Eclipse code-formatting and warning settings to be
My project uses several dll files with activex controls. Now I am making a
I'm making a 2D map-based game. The player controls one character while several AI-controlled
I'm making a customer administration software. There are several JPanels with much content on
I have a solution in VS2010 with several projects, each making up a layer
Making an adobe flex ui in which data that is calculated must use proprietary
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created

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.