# include & ltstdlib.h & gt
# include & ltstring.h & gt
int main()
{
無符號字符*字符串;
無符號字符str 1[3];/*註意這裏*/
int len
str = " abcdefg
len = strlen(str);
strncpy(str1,str+2,2);
str 1[2]= ' \ 0 ';/*這句話是必須的,但是使用strcpy()的時候,*/
printf("%d\n ",len);
printf("%s\n ",str 1);
系統(“暫停”);
返回0;
}
再來壹個:
# include & ltstudio.h & gt
# include & ltstring.h & gt
內部測試字符串(char *s)
{ char * p = s;
while (*p)
p++;
返回p-s;
}