Hi, I have a linked list which I created in a function? I want to allow the user to enter a name for the linked list, and then after he/she can display the list by typing in the title. This is part of my code

struct llistt{
char str[100];  // where the strings will be kept
struct llistt *next
struct llistt *prev

typedef struct llistt node
10 Years
Discussion Span
Last Post by Narue

Right now your list consists only of nodes. If you want data that applies to the list as a whole, you should create a new structure that contains a list as well as that data:

struct node {
  char str[100];  // where the strings will be kept
  struct node *next
  struct node *prev

struct list {
  char name[100];
  struct node *head;

typedef struct node node;
typedef struct list list;

Then you use it the same way, just instead of arbitrary pointers for the head of the list, you store it in a list object.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.