int strlen(char *s) { int i=0; while(*s!='\0') { i++; s++; } return i; } void main() { char str[100]; int len; printf("please input your string:"); gets(str); len=strlen(str); printf("the length of str is:%d\n",len); }
传入字符串,计算字符串长度(用指针实现)
最新推荐文章于 2023-08-03 16:34:51 发布