The below code explains procedure to how to create a Singly-Linked-List and Print Data in that List.
#include <stdio.h>
/*This part of the code is to create a structure in which we create the simplest entity in the List which is a Node
<Code below is definition of single Node>
The Node consists of the internal Data which can be anything from primitive data to an array to another structure.
*/
struct Node
{
int info;
struct Node *next;
};
/*Now to create a linked list what we require is a HEAD to mark the beginning of the Linked-List followed by a TEMP to track the current node being processed, followed by a Temp Definition of NEWNODE which will be created at run-time*/
int main()
{
int i = 0;
struct Node *head = (struct Node*)malloc(sizeof(struct Node));
struct Node *temp = NULL;
struct Node *newnode = NULL;