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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:19:31+00:00 2026-06-13T22:19:31+00:00

#include <stdio.h> #include <stdlib.h> void setZero (double **, int); int main (void) { double

  • 0
#include <stdio.h>
#include <stdlib.h>

void setZero (double **, int);

int main (void) {
        double *ptr = NULL;
        int i, size = 3;
        ptr = (double *)malloc(size * sizeof(double));
//*
        setZero(&ptr, size);
/*/
        // Sanity test
        for ( i = 0 ; i < size ; ++i ) {
                printf("index %d/%d\n", i, (size-1));
                ptr[i] = 0;  // NOT EXPLODING...
        }
//*/
        free(ptr);
        return 0;
}

void setZero (double **_ref_array, int _size) {
    int i;

    for ( i = 0 ; i < _size; ++i ) {
        printf("index %d/%d\n", i, (_size-1));
        *_ref_array[i] = 0;  // EXPLODING...
    }
}

1) Why is this not working?

2) What is a “Bus error 10”

P.S. I know better than to initialize an array this way, but this just happens to be a simple and clean example of an underlying concept that I’m not understanding…

  • 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-06-13T22:19:33+00:00Added an answer on June 13, 2026 at 10:19 pm

    The dereference is happening after the index. I.e.

    This says “Get the double pointer at index ‘i’, then set the value 0 to the memory at the address within that pointer.”

    *_ref_array[i] = 0; 
    

    This says “Get the address of the array of doubles from _ref_array, than index off that address by i-doubles.

    (*_ref_array)[i] = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <stdio.h> #include <stdlib.h> int main() { void *malloc(size_t size); char *ptr, *retval; ptr
The program is: #include <stdio.h> #include <stdlib.h> int main(void) { char *a=abc,*ptr; ptr=a; ptr++;
#include <stdio.h> #include <stdlib.h> int main (void) { double f; printf (What is the
#include <stdio.h> #include <stdlib.h> int main(void) { int x; int *in, *begin; in =
#include <string.h> #include <stdlib.h> #include <stdio.h> int main(void) { unsigned char *stole; unsigned char
#include <stdio.h> #include <stdlib.h> #include <time.h> #define length 100 void print_array(); int main() {
#include<stdio.h> #include<sys/types.h> #include<stdlib.h> int turn; int flag[2]; int main(void) { int pid,parent=1; printf(before vfork\n);
#include <stdio.h> #include <stdlib.h> void getstr(char *&retstr) { char *tmp = (char *)malloc(25); strcpy(tmp,
#include <stdio.h> #include <stdlib.h> #include <string.h> void main() { typedef int (FuncPtr)(); char asmFunc[]
#include <stdio.h> #include <stdlib.h> void copyint(char *i,char** temp); int main() { char* a=00313; char*

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.