Advertisement
Guest User

main.c

a guest
Nov 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "stack.h"
  3.  
  4. extern Stack theStack;
  5.  
  6. int main()
  7. {
  8. StackError_t res;
  9. uint8_t value;
  10.  
  11. res = init();
  12.  
  13. if (res == StackError_t::STACK_NO_ERROR)
  14. printf("Stack initialized successfully.\n");
  15. else
  16. return -1;
  17.  
  18. if (isEmpty())
  19. printf("The stack is empty.\n");
  20. else
  21. printf("The stack is not empty.\n");
  22.  
  23. res = push(12);
  24.  
  25. if (res == StackError_t::STACK_NO_ERROR)
  26. printf("Value pushed successfully.\n");
  27.  
  28. res = pop(&value);
  29.  
  30. if (res == StackError_t::STACK_NO_ERROR)
  31. printf("Value popped successfully.\n");
  32.  
  33. res = peek(&value);
  34.  
  35. if (res == StackError_t::STACK_VALUE_NOT_FOUND)
  36. printf("%u not found in stack.\n", value);
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement