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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:29:45+00:00 2026-05-12T07:29:45+00:00

This is code for a linked list in the C programming language. #include <stdio.h>

  • 0

This is code for a linked list in the C programming language.

#include <stdio.h>    /* For printf */
#include <stdlib.h>   /* For malloc */

typedef struct node {
    int data;
    struct node *next; /* Pointer to next element in list */
} LLIST;

LLIST *list_add(LLIST **p, int i);
void list_remove(LLIST **p);
LLIST **list_search(LLIST **n, int i);
void list_print(LLIST *n);

The code is not completed, but I think it’s enough for my question. Here at the end of struct node “LLIST” is used, and it’s also used as a return type in the prototyping of the function list_add. What is going on?

  • 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-05-12T07:29:45+00:00Added an answer on May 12, 2026 at 7:29 am

    typedef creates a new “type” in your program, so the return value and types of parameters of those functions are just your struct. It is just shorthand for using struct node for the type.

    If you were to create a new node, you could do it like this (using the type):

    LLIST *node = malloc(sizeof(LLIST));
    node->data = 4;
    node->next = someOtherItem;
    list_add(node, 1)
    

    Also, with the function prototypes in your question, you don’t really need the double pointers; since the data in your struct is just an int, you could do something like

    LLIST *list_add(int data, int position);
    

    then the list_add function would handle the allocation, copy the int into the struct and add it to the linked list.

    Putting it in at a certain position is as simple as changing the next pointer in the node before it to the address of the newly allocated node, and the next pointer in the new node to point at the next one (the one the node before that one was originally pointing at).

    Keep in mind that (given the rest of your function prototypes) you will have to keep track of pointers to every node you create in order to delete them all.

    I’m not sure I understand how the search function will work. This whole thing could be implemented a lot better. You shouldn’t have to provide the location of a node when you create it (what if you specify a higher number than there are nodes?), etc.

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

Sidebar

Ask A Question

Stats

  • Questions 183k
  • Answers 183k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer That set of behaviors was built for the beta version… May 12, 2026 at 4:42 pm
  • Editorial Team
    Editorial Team added an answer This is definitely not supported behavior, and can potentially cause… May 12, 2026 at 4:42 pm
  • Editorial Team
    Editorial Team added an answer ob_gzhandler will automatically detect if the users browser is gz… May 12, 2026 at 4:42 pm

Related Questions

This is not exactly a technical question, since I know C kind of enough
I have been working on a Java project for a class for a while
Alright, so I'm trying out C++ for the first time, as it looks like
I came across this problem while preparing for an interview and curious to know

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.