Create f2

This commit is contained in:
havya1310 2018-10-27 11:24:18 +05:30 committed by GitHub
parent 3468d27e61
commit 007ca7bcd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

19
f2 Normal file
View file

@ -0,0 +1,19 @@
struct Node *addToEmpty(struct Node *last, int data)
{
// This function is only for empty list
if (last != NULL)
return last;
// Creating a node dynamically.
struct Node *last =
(struct Node*)malloc(sizeof(struct Node));
// Assigning the data.
last -> data = data;
// Note : list was empty. We link single node
// to itself.
last -> next = last;
return last;
}