Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

prog1_3 Create a driver program that takes a single command line argument N (in addition to the name of the program being executed). The command

image text in transcribed

prog1_3 Create a driver program that takes a single command line argument N (in addition to the name of the program being executed). The command line argument N will be an integer number. If there is not a single command line argument your program should print an error message and quit. For valid inputs, your program will print a single right carrot take N lines of input from STDIN (entire line inputs). Your program will split each of these lines on a space delimiter. Your program should ignore multiple space characters (i.e. treat as many spaces in a row as a single space. It should also ignore leading and trailing spaces. For example Hello World should only result in two tokens, Hello and World. Neither token should have spaces in the string. If there are exactly two tokens AND the first token is the string push then your program should convert the second token to an integer and push the result onto your STACK. If there is exactly one token AND the token is the string pop then your program should Pop a value off of the STACK and print it to STDOUT on its own line. All other input should be ignored. Your program should only print the assignment header, the error message, the carrot at the beginning of the input line or the result of a Pop. Your program can assume that all STDIN inputs will be less than 256 characters, the command line argument will be an integer (if it exists) and the second token in a two token input that has push as the first token will be an integer.

prog1 2 and typedefs. typedef struct stack Create a header file (prog1_2.h) which will contain the following function prototypes int data; int size; int capacity: STACK: STACK MakeStack (int initialCapacity) void Push (STACK *stackPtr,int data) int Pop (STACK stackPtr) void Grow (STACK stackPtr) Create a source file (prog1_2.c) that will implement the MakeStack, Push, Pop and Grow functionality. The STACK that is produced by the MakeStack function should be able to holdinitialCapacity integers. The Grow function should double a stacks capacity without changing any of the values held by the STACK. The Push and Pop functions should work as expected for a stack. The Push function should Grow the stack if there isn't enough capacity to hold the pushed data. The Pop function should return -1 if there is no data in the STACK. Yes this is probably incorrect behavior

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

2. Outline the functions of nonverbal communication

Answered: 1 week ago