Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribedAnd 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

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

Students also viewed these Databases questions