this code has some bugs Im new to c strings. the code that i have below reverses each word. For example. i entered "house is" it reverses it to "si esuoh" I want it to reverse it by word like "is house".
My other questions since strings are pointers how do I call each one in an array?
here is my code
Code:
#include <stdio.h>
#include <string.h>
void reverse(char *sPtr);
int main (void)
{
char sentence[80];
printf( "enter a line of text:\n");
fgets(sentence,80, stdin );
printf("\nThe line printed backwards is\n");
reverse( sentence );
return 0;
}
void reverse ( char *sPtr){
if(sPtr[0] == '\0') {
return;}
else {
reverse(&sPtr[1]);
putchar(sPtr[0]);
}
}