From 007ca7bcd0109c96d5960634c59569c44dfbc9cc Mon Sep 17 00:00:00 2001 From: havya1310 <44518163+havya1310@users.noreply.github.com> Date: Sat, 27 Oct 2018 11:24:18 +0530 Subject: [PATCH] Create f2 --- f2 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 f2 diff --git a/f2 b/f2 new file mode 100644 index 00000000..32bebe17 --- /dev/null +++ b/f2 @@ -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; +}