mirror of
https://github.com/trailofbits/algo.git
synced 2025-08-14 00:33:02 +02:00
Create f2
This commit is contained in:
parent
3468d27e61
commit
007ca7bcd0
1 changed files with 19 additions and 0 deletions
19
f2
Normal file
19
f2
Normal 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;
|
||||
}
|
Loading…
Add table
Reference in a new issue