Question: #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

 #include #include void readfile(char * filename); int main(int argc, char **argv){

#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   C Programming Language Review Goal Review C Programming in Linux - command line arguments, File IO, pointers, loops, strings, malloc. 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 Example: ./Ex02 -a 12 30 O Output: 42  Option "-f ": read a file and output the content of the file O o Example: ./Ex02 -f Ex02.c. Output:   Option"-s  ": output the combined 2 strings from the command line by using pointers Example: ./Ex02 -s hello world O Output: helloworld o 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''O'' ' 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 string 2 . Declare a local variable or array will request memory space in automatic memory space "stack".  Option "-m  ": output the combined 2 strings by using dynamic memory allocation malloc. O Example: ./Ex02 -s hello CSC338 o Output: helloCSC338 o Hint: "hello" contains 5 char plus ' '. "CSC338" contains 6 chars plus ' '. Therefore, you need to use malloc to create a new string with an array of 5+6+1 = 12 to be able to hold the combined string "helloCSC338" malloc will allocate memory space in free memory space "heap". Deliverables 1. Turn in a snapshot of your program's output on Blackboard (The output should contain the results of running your program with the 4 options.). 2.Turn in your source code of ExO2.C

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!