Question: PLEASE READ THIS FIRST! PLEASE USE C! PLEASE ANSWER THE WHOLE QUESTION! MAKE SURE IT IS READABLE! QUESTION: PROGRAM STACKS LAYOUT: 1. Stacks in C

PLEASE READ THIS FIRST!

PLEASE USE C! PLEASE ANSWER THE WHOLE QUESTION!

MAKE SURE IT IS READABLE!

QUESTION:

PLEASE READ THIS FIRST! PLEASE USE C! PLEASE ANSWER THE WHOLE QUESTION!

PROGRAM STACKS LAYOUT:

MAKE SURE IT IS READABLE! QUESTION: PROGRAM STACKS LAYOUT: 1. Stacks in

1. Stacks in C (15 points) Implement a stack to store and remove strings that will be read from a file. The data file contains a series of strings, one per line. Each string will contain 255 or fewer characters Whenever you read the string "pop", this is a signal to pop your stack. Any other string should be pushed onto your stack The format of the data file is: pop pop etc. To create the initial stack, use malloc to allocate enough space to store 10 strings. Keep track of how many elements are in your stack. When you stack reaches capacity, your push method needs to allocate more space to your stack before pushing the next element (add space for another 10 strings). You can use realloc, or something else like malloc/copy/swap You do not ever need to shrink your stacks capacity. You are required to implement the following stack functions: push, pop, empty, and full create returns a new empty stack push takes a string parameter which is the value it pushes onto the stack. It may also need to call realloc to expand the size of the stack before completing the push pop returns the string that was removed from the stack empty returns TRUE if the stack has no elements, otherwise FALSE full returns TRUE if the stack does not have any room left, otherwise FALSE Your program must print the assignment 2 and your name. Additionally, each time you read "pop" (i.e., each time you receive a signal to pop the stack) you should print the # of elements in the stack after popping and also print the string that is popped off the stack You should also print a message every time your stack grows. For example, the program might print the following Assignment 2 Problem 1 by # elements after popping: 2 # elements after popping: 1 # elements after popping: 0 Stack capacity has grown from 10 elements to 20 elements string popped: Be string popped: sure string popped: to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!