In this program, I'm trying to input a sentence and print the sentence in reverse order. Like for example, if my input is "I Like You", then my output must be "You Like I". Please help me fix this code!
#include<stdio.h>
#include<string.h>
void words(char arr[], int n)
{
for(int i=n-1; i>=0; i--)
{
if(arr[i]==' ')
{
arr[i]='\0';
printf("%s ", &(arr[i])+1);
}
}
printf("%s", arr);
}
int main()
{
char x[50];
printf("Enter the sentence: ");
gets(x);
int size=strlen(x);
void words(x, size);
return 0;
}