# include & ltstring.h & gt
# include & ltstdio.h & gt
int main()
{
char s[3][80],temp[80];
strcpy(s[0],“妳可以理解如何使用strtok函數。”);
strcpy(s[1]," for(I = 0;我& lt10;i++)”);
strcpy(s[2]," sum+= n;");
char * p;
char token[]= ";=()";
for(int I = 0;我& lt3;i++)
{
strcpy(temp,s[I]);
p = strtok(temp,token);
printf("%s ",p);
做{
p=strtok(NULL,token);
如果(!p)繼續;
if(*(p-temp+s[I]-1)= '(')printf(" | ");
if(*(p-temp+s[i]-1)=“”)
printf("|%s ",p);
else if(*(p-temp+s[i]-1)!='='||*(p-temp+s[i]-2)=='+')
printf(" % c | % s " ,*(p-temp+s[I]-1),p);
其他
printf(" % c % s " ,*(p-temp+s[I]-1),p);
} while(p);
if((p=strrchr(s[i],')')= = s[I]+strlen(s[I])-1)printf(" | % c ",* p);
if((p=strrchr(s[i],';'))= = s[I]+strlen(s[I])-1)putchar(* p);
puts(" ");
}
返回0;
}
//來自:CSDN論壇