Question: Program in C Part 2: echo with a twist Write a program, named twecho, that takes words as command line argunents, and printa each word

 Program in C Part 2: echo with a twist Write a

Program in C

Part 2: echo with a twist Write a program, named "twecho", that takes words as command line argunents, and printa each word twice, once as is and once all-capitalized, separated by a space. For example, /twecho hello world dude should output: hello HELLO world WORLD dude DUDE Your progzam should handle any number of arguments. You can receive the command line arguments if you start your main function in the Eollowing way: int main int argc, char **argv) iere are some requirements and hints: - You must use the main) funetion exactly as given below You CANNOT modify the main function Your job is to implement other functiona that main calls int main(int argc, char **argv) if (argc tring . h> -You can put duplicateArgs() and freeDuplicatedArgs() in the same . c file as mainO - In duplicateArgs function, you are making a "copy" of the memory structure shown in the picture on page 115, KSR2 You will call malloc once for the overali array where each element is of type char*, then you will call malloc for each element of that array, each of which will hold the all-cap version of each argument. of course, you wi1l have to copy each string character-by-character, capitalizing as you go and Some useful library functions for doing this include strlen toupper See the textbook Don't forget that the last element of the overall array of char*'s is a NULL pointer (see the picture in page 115, K&R2) - In freeDuplicatedArgs) function, you must free( everything you malloe ed. First free) all individual strings, and the Eree) the overall array Part 2: echo with a twist Write a program, named "twecho", that takes words as command line argunents, and printa each word twice, once as is and once all-capitalized, separated by a space. For example, /twecho hello world dude should output: hello HELLO world WORLD dude DUDE Your progzam should handle any number of arguments. You can receive the command line arguments if you start your main function in the Eollowing way: int main int argc, char **argv) iere are some requirements and hints: - You must use the main) funetion exactly as given below You CANNOT modify the main function Your job is to implement other functiona that main calls int main(int argc, char **argv) if (argc tring . h> -You can put duplicateArgs() and freeDuplicatedArgs() in the same . c file as mainO - In duplicateArgs function, you are making a "copy" of the memory structure shown in the picture on page 115, KSR2 You will call malloc once for the overali array where each element is of type char*, then you will call malloc for each element of that array, each of which will hold the all-cap version of each argument. of course, you wi1l have to copy each string character-by-character, capitalizing as you go and Some useful library functions for doing this include strlen toupper See the textbook Don't forget that the last element of the overall array of char*'s is a NULL pointer (see the picture in page 115, K&R2) - In freeDuplicatedArgs) function, you must free( everything you malloe ed. First free) all individual strings, and the Eree) the overall array

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!