當前位置:編程學習大全網 - 網站源碼 - Cstrtok函數源代碼

Cstrtok函數源代碼

//以下是本題的源代碼(待優化)

# 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論壇

  • 上一篇:oppo手機如何root?
  • 下一篇:為什麽會有“密碼輸錯三次就鎖定賬戶”的設定?
  • copyright 2024編程學習大全網