Question: Use command line parameters, function pointers and C library string functions, and create a Makefile Mandatory file names: lab3p2.h lab3p2.c lab3p2f1.c lab3p2f2.c lab3p2f3.c Makefile This
Use command line parameters, function pointers and C library string functions, and create a Makefile
Mandatory file names: lab3p2.h lab3p2.c lab3p2f1.c lab3p2f2.c lab3p2f3.c Makefile
This program should execute the following command entered at the command line:
% lab3p2 func_type string1 string2
where the three possible func_types are:
func_type == 1: Concatenate string1 with string2, separated by a single blank (white space)and print the concatenated string.
E.g., given the command line entry: % lab3p2 1 Go Bucks!
The output should be: Go Bucks!
func_type == 2: Determine if string1 and string2 are the same string (case matters).
E.g., given the command line entry: % lab3p2 window winnow
The output should be:string1 is not the same as string2
func_type == 3: Convert all the uppercase characters in string1 to lowercase, and vice-versa.
E.g., given the command line entry: % lab3p2 3 aWESOME! gREat
The output should be: string1 with inverted case is: Awesome!
Be sure to error-catch the following, and print an appropriate error message:
Incorrect func_type number (i.e., not 1, 2, or 3).
An invalid number of command line arguments (that is, greater than 3 or less than 3).
CONSTRAINTS
You are required to write your own functions, but you can (and should) use string functions in the C library instead of writing your own code to perform functionality which they provide).
Be sure to write output to the screen with messages similar to the ones given above.
You should declare an array of function pointers, and use the array to call the appropriate function (1, 2, or 3) depending on what the user enters on the command line).
Similar to the example in class, put each of the functions into its own .c file (see the required file names to submit, and you should be able to determine which functions to put into which files), and create a lab3p2.h header file with function declarations. Finally, create a Makefile with dependencies, multiple tags, and a clean option, and make sure that your program builds successfully with make.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
