Skip to content

Commit 8d63bec

Browse files
authored
Update stack_using_linked_lists.c
1 parent 9a70599 commit 8d63bec

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

data_structures/linked_list/stack_using_linked_lists.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void push(struct node *p)
4343
{
4444
int item;
4545
struct node *temp;
46-
temp = (struct node *)malloc(sizeof(struct node)); //creating memory for temp node.
46+
temp = (struct node *)malloc(sizeof(struct node));
4747
printf("enter element to be inserted\n");
4848
scanf("%d", &item);
4949
temp->info = item;
@@ -62,21 +62,21 @@ void pop(struct node *p)
6262
int item;
6363
struct node *temp;
6464

65-
if (top == NULL) // Underflow condition
65+
if (top == NULL)
6666
printf("stack is empty\n");
6767
else
6868
{
6969
item = top->info;
7070
temp = top;
71-
top = top->link; // new top will be the node pointed by previous top.
72-
free(temp); // free the memory of node using free().
71+
top = top->link;
72+
free(temp);
7373
printf("Element popped is%d\n", item);
7474
}
7575
}
7676

7777
void display(struct node *p)
7878
{
79-
if (top == NULL) // Underflow condition
79+
if (top == NULL)
8080
printf("stack is empty\n");
8181
else
8282
{

0 commit comments

Comments
 (0)