一道C语言题目 int fun(char s[]) { char *p=s; while(*p!=0) p++; return(p-s); }

日期:2015-03-04 10:47:14 人气:1

一道C语言题目 int fun(char s[]) { char *p=s; while(*p!=0) p++; return(p-s); }

while(*p!=0) p++; 导致最终p指针指向了字符串结束符'\0',其余字符串首指针s的差值即字符串长度 该函数功能等效于库函数strlen()
    A+
热门评论