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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:15:10+00:00 2026-06-11T12:15:10+00:00

This is the prototype for the function, sum , I am using to summate

  • 0

This is the prototype for the function, sum, I am using to summate the elements of two arbitrary arrays.

double **sum(double **A, double **B, int M, int N);

They’re both passed as double-pointers (don’t ask why) and M and N are supposed to be the dimensions of the arrays respectively.

What I’m having trouble doing is, within the implementation of the function, accessing elements of the arrays. I’ve tried “deferencing” the array (or so I think) but to no avail. Below are the things I’ve tried:

> *A;  // Gives me an address, 0xf5c28f5c, not a number
> **A; // Error
> &A;  // Gives me the address of A

This is how I’m passing the arrays to sum if it’s helpful:

double a[] = {5.34, 5.23, 6.5, 3.51};
double b[] = {74.3, 42.1, 642.2, 54.2};

sum( (double **) a, (double **) b, 4, 4);

So the question is, how exactly am I supposed to get the elements in the arrays when passed by pointer/double-pointer?

  • 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-11T12:15:11+00:00Added an answer on June 11, 2026 at 12:15 pm

    Your array passage to your function is entirely incorrect. A double pointer is best to be thought of as a pointer-to-pointer. In the same way a pointer is a variable that holds the address to memory someplace, a pointer-to-pointer holds a similar address, it just so happens the memory it references is the memory occupied by another pointer. This is best described by example:

    include <stdio.h>
    
    int main(int argc, char* argv[])
    {
        int a = 5;
        int *p = &a;
        int **pp = &p;
        printf("pp=%p, &p=%p, p=%p, &a=%p *p=%d\n", pp, &p, p, &a, *p);
        return 0;
    }
    

    On my MBA 64bit, this give us:

    pp=0x7fff50828bc8, &p=0x7fff50828bc8, p=0x7fff50828bd4, &a=0x7fff50828bd4 *p=5
    

    Get a grasp on that and I think you’ll find your issues in your code, the first of which is the hard cast to a double pointer of ‘a’ and ‘b’. Maybe try their addresses instead. Secondly, you will likely want to revisit how you’re using those pointers for dereferences in your function, because chances are that needs work too.

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

Sidebar

Related Questions

I have the below prog Object.prototype.inherit = function(baseConstructor) { this.prototype = (baseConstructor.prototype); this.prototype.constructor =
So there is this function Array.prototype.containsCaseInsensitive = function(obj) { var i = this.length; while
From: http://ejohn.org/apps/learn/#2 Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object =
When I pass 'this' to an anonymous function like so: MyClass.prototype.trigger = function(){ window.setTimeout(function(){this.onTimeout();},1000);
function MyClass(projectName) { this.projectName = projectName; } MyClass.prototype.createHttpRequestObject = function() { /* do something
$.Comment = function() { this.alertme = Alert!; } $.Comment.prototype.send = function() { var self
function Person() {} Person.prototype.population = 0; Person.prototype.constructor = function(name) { this.name = name; console.log(Name:
Is this possible? function testObj(testArg) { //Do obj stuff here } testObj.prototype.addFn = function()
var Dog = function(name) { this.name = name; this.sayName(); } Dog.prototype.sayName = function() {
In the code below: DbModels.prototype.updateById = function(_collection, id, field, value, callback) { this.getCollection(_collection, function(error,

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.