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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:03:20+00:00 2026-06-09T22:03:20+00:00

void push(struct node** head_ref, int new_data) { /* allocate node */ struct node* new_node

  • 0
void push(struct node** head_ref, int new_data)
{
    /* allocate node */
    struct node* new_node =
            (struct node*) malloc(sizeof(struct node));

    /* put in the data  */
    new_node->data  = new_data;

    /* link the old list off the new node */
    new_node->next = (*head_ref);   

    /* move the head to point to the new node */
    (*head_ref)    = new_node;
}

If i remember correctly, putting a brackets on a pointer means calling a function?
If that’s true i don’t really understand why there are brackets on *head_ref.
Id love a little explanation on why do i need brackets on *head_ref in this code.

  • 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-09T22:03:21+00:00Added an answer on June 9, 2026 at 10:03 pm

    In this particular case, the brackets are serving no purpose other than to clarify the programmer’s intent, i.e. they they want to dereference head_ref.

    Note that head_ref is a pointer to a pointer, so in this case, new_node->next is being set to point to the original head of the linked list, and then the pointer pointed to by head_ref is being updated to point to new_node which is now the start of the list.

    As Michael Krelin has pointed out below, putting brackets around a pointer do not mean it’s a calling a function, or a pointer to a function. If you saw this: (*head_ref)() then it would be a call to the function pointed to by head_ref.

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

Sidebar

Related Questions

#include<stdio.h> #include<conio.h> #include<alloc.h> struct node { int data; struct node*link; }; void push(struct node*,int);
here's my code class LList{ struct Elem{int data;Elem *next;}; Elem *head; public: void Push(int
I have the following class: class Stack { struct Link { void* data; Link*
Will this code ever wait on the mutex inside the producer's void push(data) ?
void foo(Node* p[], int size){ _uint64 arr_of_values[_MAX_THREADS]; for (int i=0 ; i < size
I have a node struct and stack class. When I put the definition for
I am writing a dynamic array in C. typedef struct __c_array { void**_elem; int
typedef struct { nat id; char *data; } element_struct; typedef element_struct * element; void
public void CardToPile() { waste.push(reserve.pop); }
- (void)TargetHit:(int)target{ void (^threadBlock)(void) = ^{ NSLog(@respond to selector %d, [self respondsToSelector:@selector(changeImageOfTarget:)]); [[NSOperationQueue mainQueue]

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.