I have to write a function, which has to reverse each characters of words in a given string as example: Original string: Hello World and the Reversed string must be: olleH dlroW. What I am doing is, that I'm looping the string until it finds '\0' and then loop inside until there is a space. When I find the space then I print the string reversed, but my problem is that it prints only the first word reversed and not the whole string, I don't know how to jump to the next character after I have found the space and then reverse it. In my task I can't use string.h library.
int main(void)
{
char *text = "Hello World";
int i, j;
while(text[i] != '\0')
{
if(text[i] != ' ')
{
for(j = i - 1; j >= 0; j--)
printf("%c", text[j]);
}
i++;
}
return 0;
}