void foo(char *s)
{
int i = 0;
while (s[i] != '\0')
{
if (s[i] == ' ')
{
s[i] = '\0';
foo(s + i + 1);
printf("%s ", s);
break;
}
i++;
}
}
int main()
{
char s[] = "welcome to learn c";
foo(s);
}
void foo(char *s)
{
int i = 0;
while (s[i] != '\0')
{
if (s[i] == ' ')
{
s[i] = '\0';
foo(s + i + 1);
printf("%s ", s);
break;
}
i++;
if (s[i] == '\0') printf("%s ", s); //--------------->修改
}
}
int main()
{
char s[] = "welcome to learn c";
foo(s);
}