11问答网
所有问题
int a(char *s) {char *t=s; while (*t++); t--; return(t-s);}
解释一下每个语句的意思,怎么求出字符串s的长度的?
举报该问题
推荐答案 2014-06-23
char *t=s; t指向s其始; while (*t++); 取t的内容,t指针+1;当t指到末尾时*t返回0,循环结束。t指针再+1。 t--; t指针减1,指到字符串尾。 return(t-s); 返回末尾和起始的差,也就是字符串长度。
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://11.wendadaohang.com/zd/F77P27qFMF2F4M4S2q7.html
相似回答
...
int
aaa
(char
*s)
{ char
*t=s;
while(*t++);
t--;
return(t-s
...
答:
回答:选a ,一定要注意
while
语句后面的分号
大家正在搜
unsigned char
unsigned int
java char转int
static c语言
c语言int转char
char *s
char和int
char转化int
char和int的区别
相关问题
有以下函数 int fun(char *s) {char *...
C语言中while(*t++)什么意思?还有 int aaa...
有下列函数: int fun(char*s) {char*t...
int aaa(char *s) { char *t=s; ...
int fun(char *s) { char *t=s; ...
在c语言中 int aaa(char *s) {char *...
int aaa(char *s)
while(*t++)问题