Question: How do I complete this program based on command lines using C? Here's the assignment given: And here's the skeleton program given: #include #include void

How do I complete this program based on command lines using C?

Here's the assignment given:

How do I complete this program based on command lines using C?And here's the skeleton program given:

#include #include

void readfile(char * filename);

int main(int argc, char **argv){ //argv[0] is the program name //argv[1], argv[2], argv[3] are the 1st, 2nd, and 3rd argument in the command line arguments

if(argc

return 0; }

//function for -f reading a file void readfile(char * filename) { //implement your file reading }

Procedure Write a C program Ex02.c that performs one of the four operations based on command line arguments to the program. Please DO NOT use string libraries on this assignment. The possible command line options and the associated operations are as follows: Option "-a 12 30": read two integers from the command line arguments and output the sum of the two integers O Example: ./Ex02 -a 12 30 o Output: 42 Option"-f ": read a file and output the content of the file Example: ./Ex02 -f Ex02.c O Output: Option "-s ": output the combined 2 strings from the command line by using pointers. O Example: ./Ex02 -s hello world o Output: helloworld Hint: AC type string is an array of char with the length of the number of characters plus a null character. For example: "hello" in C is stored as 'h''e''l'l'ol' ' which makes the "hello" array with the length of 6. You can declare a large new char array and use pointers to copy stringl and then string2 Declare a local variable or array will request memory space in automatic memory space "stack". Option "-m

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!