/monty

Primary LanguageC

0x19. C - Stacks, Queues - LIFO, FIFO

0. push, pall

Implement the push and pall opcodes.

The push opcode

The opcode push pushes an element to the stack.

  • Usage: push
    • where is an integer
  • if is not an integer or if there is no argument given to push, print the error message L<line_number>: usage: push integer, followed by a new line, and exit with the status EXIT_FAILURE
    • where is the line number in the file
  • You won’t have to deal with overflows. Use the atoi function

The pall opcode

The opcode pall prints all the values on the stack, starting from the top of the stack.

  • Usage pall
  • Format: see example
  • If the stack is empty, don’t print anything

1.pint