#include<stdio.h>
void cpy(char *s, char **o)
{
while(**o!= '\0' && **o != ' ')
{
*s = **o;
(*o)++;
s++;
}
*s = '\0';
return;
}
void cpy2(char **s,char *o)
{
if(**s == '\0')
{
**s = ' ';
(*s)++;
}
while(*o != '\0')
{
**s = *o;
(*s)++;
o++;
}
**s = '\0';
}
void test(char *p)
{
static char *ep = p;
char s[20];
cpy(s,&p);
if(*p != '\0')
test(p+1);
cpy2(&ep,s);
}
int main()
{
char a[] = "student a am i ";
test(a);
puts(a);
return 0;
}
C 反转字符串中的单词 "student a am i " --> "i am a student "
最新推荐文章于 2024-07-11 22:10:28 发布