#include"string.h" main() { static char st1[30]="My name is "; int st2[10]; printf("input your name:/n"); gets(st2); strcat(st1,st2); puts(st1); } static char st1[30]="My name is "; int st2[10]; printf("input your name:/n"); gets(st2); strcat(st1,st2); 本程序把初始化賦值的字符數組與動態賦值的字符串連接起來。 要注重的是,字符數組1應定義足夠的長度,否則不能全部裝入被連接的字符串
#include"string.h" main() { int k; static char st[]="C language"; k=strlen(st); printf("The lenth of the string is %d/n",k); } 更多內容請看C/C++進階技術文檔專題,或 程序舉例