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'm making a WinForms app with a ListView set to detail so that several
I have a helper function, which basically calls CompareTo on two objects, but does
I have an ASP.NET MVC web application that makes REST style web service calls
I am trying to create a function with a variant record-type parameter that allows
This is beyond both making sense and my control. That being said here is
I have a legacy function that looks like this: int Random() const { return
I'm working with CakePHP 1.3. I'm making an AJAX call where I want the
So I'm making a drawing app that uses flash. I want to be able
I'm making a program that imports a custom widget that is a class (it
Making echo of a question around the web: Is the syntax for svn:ignore patterns

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.