Question: C PROGRAMMING QUESTION! This program works, (it is supposed to return a reversed string) but my assignment is to have the string print in main()

C PROGRAMMING QUESTION! This program works, (it is supposed to return a reversed string) but my assignment is to have the string print in main() how can I edit the code to do this? Thank you!

#include

#define STRINGLENGTH 100 void reverse(char*); int main() { char words[STRINGLENGTH]; char *p; p = words;

printf("I reverse strings! Enter a string: "); fgets(words, 100, stdin);

printf("The reversed string is: ");

reverse(p);

return 0;

}

void reverse(char *p) { char x; int end = strlen(p)-1;

for (x = end; x >= 0; --x) { printf("%c", p[x]); } }

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!