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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:18:00+00:00 2026-06-10T09:18:00+00:00

I am working with a double linked list in C and I came across

  • 0

I am working with a double linked list in C and I came across something that I realised I just always kind of accepted as fact or once knew the answer to and have now forgotten. This often happens to me when I start using pointers again and I end up having to re-learn them each time.

Here is the basics of my setup:

int main(void)
{
    video *head = NULL;
    video *tail = NULL;

    char *buffer = NULL;
    buffer = (char*)malloc(sizeof(MAX_TITLE_LENGTH));

    printf("Enter a title: ");
    fgets(buffer, MAX_TITLE_LENGTH, stdin);

    insert(buffer, &head, &tail);
}

I have a structure:

typedef struct video
{
    char title[MAX_TITLE_LENGTH];
    struct video *prev;
    struct video *next;
}video;

Prototype for insert:

int insert (char *title, video **head, video **tail);

and I am wondering why I have to pass the video *’s address specifically.

I know that the way I pass the char, it passes the address in memory of the beginning of the string. Why do I have to de-reference the head and tail a second time to access their values?

This is honestly more simple than I am thinking it is, I am sure of it, and I have my brain in a bad spot thinking about pointers.

Can anyone jar it loose?

Thanks.

  • 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-10T09:18:02+00:00Added an answer on June 10, 2026 at 9:18 am

    It’s because the function insert might need to change what head and tail point to.

    Remember that in C, function parameters are pass-by-value. This is why you pass a pointer to a struct that you want to change in a function: providing a pointer allows your function access to the actual structure in memory.

    But that pointer to the struct is passed by value. What if you want to change what the pointer points to? You’ll need an additional level of reference, or the memory that actually holds the pointer, so that it won’t simply be copied. With the additional level if reference, you’ll have access to the pointer to change it in the function, and can make the pointer point to something else.

    You’ll often see this in linked list code, that needs to modify e.g. the head element: all the other elements in the list are – presumably – accessible by using the pointers contained in each node in the list, but if you need to e.g. insert a new element at the head, your function will need to change the head pointer. If you pass it in as a function parameter, you’ll need it’s address, otherwise the function would only be changing a copy, and the changes aren’t reflected outside the function.

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

Sidebar

Related Questions

I'm working on a hybrid data structure that is an ordered double-linked list where
I have a simple doubly linked list example that I'm working on, but for
I'm working on a C program that generates a doubly linked list of records.
I am working with a double linked list and I have run into a
Hello I have a double linked list set up, and i have a search
I'm working on a linked list for school and I am getting a ton
I have been working with a doubly linked list. Everything works OK with the
I'm doing a doubly linked list. As far as I know it is working
I have a double linked list (queue) I have made on my own. I
Working on a search method for my doubly linked list. I'm getting exceptions but

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.