Question: How can I alter this c program so that it stores multiple data input strings from the user into an array, and prints the array's

How can I alter this c program so that it stores multiple data input strings from the user into an array, and prints the array's contents reversed only after done is entered by the user? I am having a difficult time utilizing memory allocation and pointers. Right now the program performs in a way which it takes input lines one by one and prints the reverse immediately after.

How can I alter this c program so that it stores multiple

. WNP X #include #include #define MAXC 50 /* if you need a constant, #define one (or more) */ main.cx 1 2 3 4 5 6 7 8 9 10 11 Fint main(void) { char userText [MAXC]; size_t len = 0; for (;;) { /* loop continually */ fputs ("\Insert the strings you would like reversed: ", stdout); if (!fgets (userText, MAXC, stdin)) /* validate EVERY user-input */ return 1; /* prompt for input (optional) */ 15 16 17 91234998 userText[(len = strcspn (userText, " "))] = 0; /* trim , save den */ if ((len == 1 && *userText == strcmp (userText, "Done") strcmp (userText, "done") return 0; } 'd') IL 1 0) { /* check for 'd' alone */ /* check for "Done" */ /* check for "done" */ == 20 21 22 23 24 25 26 27 28 29 30 31 32 fputs ("reversed: ", stdout); while (len--) putchar (userText[len]); putchar (' '); /* prefix for output (optional) */ /* loop hen times */ /* output char (end-to-start) */ /* tidy up with newline */ } return 0; }

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!