mirror of
https://github.com/trailofbits/algo.git
synced 2025-08-15 17:23:07 +02:00
Create f4
This commit is contained in:
parent
3468d27e61
commit
d1c2ae2de6
1 changed files with 18 additions and 0 deletions
18
f4
Normal file
18
f4
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
struct Node *addBegin(struct Node *last, int data)
|
||||||
|
{
|
||||||
|
if (last == NULL)
|
||||||
|
return addToEmpty(last, data);
|
||||||
|
|
||||||
|
// Creating a node dynamically.
|
||||||
|
struct Node *temp
|
||||||
|
= (struct Node *)malloc(sizeof(struct Node));
|
||||||
|
|
||||||
|
// Assigning the data.
|
||||||
|
temp -> data = data;
|
||||||
|
|
||||||
|
// Adjusting the links.
|
||||||
|
temp -> next = last -> next;
|
||||||
|
last -> next = temp;
|
||||||
|
|
||||||
|
return last;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue