Last active
March 16, 2016 04:19
-
-
Save ObjSal/2444540da062e837ff9a to your computer and use it in GitHub Desktop.
Stack using singly-linked list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Stack.h | |
// Data Structures | |
// | |
// Created by Salvador Guerrero on 3/15/16. | |
// Copyright © 2016 ByteApps. All rights reserved. | |
// | |
/* | |
* Stack using singly-linked list | |
* | |
* A samples can be found at: https://github.com/ObjSal/Data-Structures | |
*/ | |
#include "List.h" | |
#ifndef Stack_h | |
#define Stack_h | |
typedef struct list Stack; | |
void stack_push(Stack **stack, item_type item) | |
{ | |
list_insert(stack, item); | |
} | |
Stack* stack_pop(Stack **stack) | |
{ | |
Stack *popped_node = *stack; | |
*stack = (*stack)->next; | |
popped_node->next = NULL; // this is now a standalone node. | |
return popped_node; | |
} | |
#endif /* Stack_h */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment