Write a program that takes one string input and reverse the string in such a way that [4] each word will be reversed in its own position.
#include<stdio.h>
void rev(char str[], int start, int end)
{
char temp;
while(start<end)
{
temp=str[start];
str[start]=str[end];
str[end]=temp;
start++;
end--;
}
}
int main()
{
char str[1000];
printf("Please input your string:");
gets(str);
int start, end;
end=0;
start=0;
while(str[end])
{
for(end=start;str[end]&&str[end]!=' ';end++);
rev(str, start, end-1);
start=end+1;
}
printf("%s ",str);
return 0;
}