Created basic linked list
This commit is contained in:
Executable
BIN
Binary file not shown.
@@ -0,0 +1,26 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "linkedlist.h"
|
||||||
|
|
||||||
|
Node *head = NULL;
|
||||||
|
|
||||||
|
void insert(int data)
|
||||||
|
{
|
||||||
|
Node *newNode = malloc(sizeof(Node));
|
||||||
|
|
||||||
|
newNode->data = data;
|
||||||
|
newNode->next = head;
|
||||||
|
|
||||||
|
head = newNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void display()
|
||||||
|
{
|
||||||
|
Node *temp = head;
|
||||||
|
|
||||||
|
while(temp != NULL)
|
||||||
|
{
|
||||||
|
printf("%d ", temp->data);
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef LINKEDLIST_H
|
||||||
|
#define LINKEDLIST_H
|
||||||
|
|
||||||
|
typedef struct Node
|
||||||
|
{
|
||||||
|
int data;
|
||||||
|
struct Node *next;
|
||||||
|
|
||||||
|
} Node;
|
||||||
|
|
||||||
|
void insert(int data);
|
||||||
|
void display();
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user