65,186
社区成员




int main()
{
char a[100]="jump the computer";
char *b=strtok(a," ");
while(b!=NULL)
{
b=strtok(NULL," "); ///注意这里最后一次将返回b=NULL,而在piglatin中对*b返回,非法...
piglatin(b);
}
return 0;
}
#include <iostream.h>
#include <string.h>
void piglatin(char *a)
{
char *b=a;
char c=*b;
char *e="ay";
char d[20]="";
char *f=d;
for(int z=0;*b!='\0';b++,z++)
{
if(*(b+1)!='\0')
d[z]=*(b+1);
else
d[z]=c;
}
strcat(d,e);
cout < <d < <'\n';
}
int main()
{
char a[100]="jump the computer";
char *b=strtok(a," ");
piglatin(b); //输…
[/Quote]