Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

Complete YOUR ANSWER HERE and # your code here

Answered: 1 week ago