here's an example of a linked list.
Code:
#include <stdio.h>
#include <stdlib.h>
struct node
{
char letter;
struct node *next;
};
typedef struct node node;
node *strtolist(char *s);
int main()
{
node *list = strtolist("How to print the values of a part of a linked list");
node *temp, *next;
for (temp = list; temp; temp = next)
{
next = temp->next;
putchar(temp->letter);
free(temp);
}
putchar('\n');
return EXIT_SUCCESS;
}
node *strtolist(char *s)
{
node *list = NULL;
node *temp;
for (; *s; s++)
{
if (!list)
{
list = malloc(sizeof(node));
list->letter = *s;
list->next = NULL;
}
else
{
for (temp = list; temp->next; temp = temp->next) ;
temp->next = malloc(sizeof(node));
temp->next->letter = *s;
temp->next->next = NULL;
}
}
return list;
}