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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:37:49+00:00 2026-06-09T10:37:49+00:00

struct node { int data; struct node *next; }; What is difference between following

  • 0
struct node
{
 int data;
 struct node *next;
};

What is difference between following two functions:

void traverse(struct node *q)
{ }

and

void traverse(struct node **q)
{ }

How can i call above functions from main program?

  • 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-09T10:37:51+00:00Added an answer on June 9, 2026 at 10:37 am

    The first argument list passes a pointer to a struct node. This allows you to change the struct node in the body of the function. For instance:

    // this will change the structure, caller will see the changes:
    q->data = newValue;
    
    // but this will only change q in the function, caller WON'T see the NULL:
    q = NULL;
    

    The second argument list passes a pointer to a pointer to a struct node. This allows you to not only change the struct node in the body of the function, but also to change what the pointer points to. For instance:

    // this will change the structure, caller will see the changes:
    (*q)->data = newValue;
    
    // This will change the pointer, caller will now see a NULL:
    *q = NULL:
    

    As for calling the two versions of the function, from main or otherwise: given a pointer to your structure: struct node *arg;,

    • you could call the first version like this: traverse(arg);
    • and the second version like this: traverse(&arg);

    Alternately, given a structure declared as struct node arg;, you can make a pointer to it:

    struct node arg;
    struct node *ptrToArg = &arg;
    

    And then:

    • you could call the first version like this: traverse(&arg);
    • and the second version like this: traverse(&ptrToArg);
    • 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> struct node { int data; struct node *next; }; void insert( struct
struct node{ int data; struct node * next; }; How does the compiler allocate
struct node { int data; struct node *next; }; struct node * list,root; list=NULL;
struct Node { int value Node* next; } typedef List Node* const Set operator
struct node { node(int _value, node* _next) : value(_value), next(_next) {} int value; node*
I have following method in the c code. void add(int number) { Node node1;
#include <iostream> using namespace std; struct list { int data; list *next; }; list
Is it valid to do the following struct foo { int data; struct rb_node
struct node { int id; float weight; }; int find_last(struct node Prio_Q[]) { int
struct Edge; struct Node { int id; vector<Edge> *edges; }; struct Edge { int

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.