Question: C PROGRAMMING This is the skeleton code. Write 2 functions get_malloc_size() and fill_result() to get a result like this Write a program, named twecho, that
C PROGRAMMING
This is the skeleton code. Write 2 functions get_malloc_size() and fill_result() to get a result like this
Write a program, named "twecho", that takes words as command line arguments, and prints 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 program should handle any number of arguments: hello world dude bla blo ble
===> OUTPUT:
hello HELLO
world WORLD
dude DUDE
bla BLA
blo BLO
ble BLE
JUST FILL OUT 2 functions get_malloc_size() and fill_result(). DO NOT MODIFY ANYTHING in main()
/*
* tweeko.c
*/
#include
#include
#include
#include
/*
* Write get_malloc_size() from scratch here.
*/
// YOUR CODE GOES HERE
/*
* Write fill_result() from scratch here.
*
* - Use toupper() to convert a character to upper case.
*/
// YOUR CODE GOES HERE
/* ----- Do NOT modify anything below this line ----- */
int main(int argc, char **argv)
{
char **words = argv + 1; // skip program name
char *result = malloc(get_malloc_size(words));
fill_result(words, result);
char *r = result;
while (*words) {
printf("%s %s ", *words++, r);
while (*r++)
;
}
free(result);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
