Linked list program, don't understand it fully
my program doesn't work like it should. I know whats not working, I just don't know how to fix it. In the program I keep replacing start with temp. I'm new to the concept and pretty confused.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main()
{
struct node
{
int value;
node *next;
};
node * temp;
node * start;
node * end;
temp = new node;
temp ->value =5;
temp ->next = NULL;
start = temp;
temp = new node;
temp ->value =2;
temp ->next = NULL;
start = temp;
temp = new node;
temp ->value =7;
temp ->next = NULL;
start ->next = temp;
for(node *s = start; s; s = s->next)
{
printf("Number : %d\n", s->value);
}
system("pause");
}
I am aware I don't use "end" in the program. I have been changing things and haven't used it in the current version.