传入字符串,计算字符串长度(用指针实现)

it2025-06-08  14

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); }

转载于:https://www.cnblogs.com/bhlsheji/p/5327671.html

最新回复(0)