Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include "stack.h"
- # include <iostream>
- void push(list *userList, int numToAdd)
- {
- list *first = NULL;
- if (userList->next == NULL)
- {
- userList->num = numToAdd;
- //return(userList);
- }
- else
- {
- std::cout << "before" << userList << std::endl;
- first = new list;
- first->next = userList;
- first->num = numToAdd;
- userList = first;
- //return(first);
- }
- }
- int pop(list *userList)
- {
- list *curr = userList->next;
- int numToReturn = userList->num;
- if (numToReturn !=NULL)
- {
- std::cout << numToReturn << std::endl; // this line is for testing, to print the numbers to the screen
- delete userList;
- userList = curr;
- return(numToReturn);
- }
- else
- {
- delete userList;
- std::cout << "NULL" << std::endl; // this line is for testing, to print the numbers to the screen
- return(NULL);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement