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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:01:48+00:00 2026-06-15T00:01:48+00:00

I am storing my information in an array of pointers to structs. In other

  • 0

I am storing my information in an array of pointers to structs. In other words, each element of the array is a pointer to a linked list.

I don’t know how long the array should be, so instead of initializing the array in my main() function, I instead intialize the double pointer

struct graph** graph_array;

Then once I obtain the length of the array, I try to initialize each element of graph_array using a function GraphInitialize:

    int GraphInitialize(struct graph ***graph_array, int vertices)
    {
      *graph_array = malloc(sizeof **graph_array * vertices);
      if (*graph_array)
      {
        int i;
        for (i = 0; i < vertices; i++)
        {
          (*graph_array)[i] = NULL; // parentheses matter here!
        }
      }
      else
      {
        return -1;
      }

      return 0;
    }

But here’s the problem: I don’t call GraphIntialize directly from main(). Instead, I first call getdata() from main, and pass a pointer to graph_array to getdata as shown below.

    getdata(argc, argv, vertpt, edgept, &graph_array)

    int getdata(int argc, char *argv[], int *verts, int *edges, struct graph* **graph_array)

Then getdata retrieves the number of vertices from my input file, and uses that to call GraphInitialize:

    if ((GraphInitialize(&graph_array, *verts)) == -1)
    {
      printf("GraphCreate failed");
      return 0;
    }

This results in an error: “expected ‘struct graph 3ASTERISKS (triple pointer)’ but argument is of type ‘struct graph 4ASTERISKS (quadruple pointer)’. This is so confusing. If there is a way I can work this out without needing all these pointers that might be the best answer, but I am trying to create and abstract data type and so I don’t want to be creating a graph_array array in my main function.

  • 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-15T00:01:49+00:00Added an answer on June 15, 2026 at 12:01 am

    I suppose, you don’t have to use ‘&’ here:

    if ((GraphInitialize(&graph_array, *verts)) == -1)
    

    You want to initialize a double pointer (graph**), but to do that you pass a pointer to it into your functions, so both of them get a triple pointer (graph ***) as an input.
    The chain of calls looks something like this (this is more of a pseudocode):

    void GraphInitialize(struct graph *** graph_array);
    
    void getdata(..., struct graph *** graph_array )
    {
        ...
        GraphInitialize(graph_array); //graph_array here is the same triple pointer, that 'getdata' recieved as an input, so there is no need to use '&' operator.
        ...
    }
    
    void main() 
    {
        graph ** graph_array = ...; // this is a double pointer, obviously
        getdata( ..., &graph_array); //getdata gets a triple pointer as an input, so we get the graph_array address by '&' operator;
    }
    

    So the correct form would be

    if ((GraphInitialize(graph_array, *verts)) == -1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am storing my information in an array of pointers to structs. In other
I want to have a List or Array of some sort, storing this information
hi all i am getting three types of array list information storing in one
I am running an image analysis code on an array storing information about the
I'm dynamically storing information in the database depending on the request: // table, id
I'm building a WebApp in jsf 2.0 and it's about storing information and displaying
I have 2 tables - one storing user information (id, username, password) and the
Whats the recommended way for storing authentication information in iOS that could be easily
Storing credit card information securely and legally is very difficult and should not be
I am retrieving information from my database and storing it in a reader. The

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.