creation of first node in linked list
paste it and run this code..
//CREATING A NODE Against LinkedList IN C
#include
#include
#include
#include
//defining a datatype
struct node
//'struct' is keyword and 'node' is a tag
{
int data;
struct node *next;
};
struct node *head=0;
int main()
{
int *newnode;
newnode=(struct node*)malloc(sizeof(struct node));//malloc returns a void pointer so we have to pointer cast
printf("enter the data");//asking of data
scanf("%d",&newnode->data);//pasting the element at data part
newnode->next=0;
head=newnode;
}
if any further assistance required then please do contact.
Comments
Post a Comment