指针后面有中括号表示什么main(){char st[20],*ps;int i;printf("input a string:\n");ps=st;scanf("%s",ps);for(i=0;ps[i]!='\0';i++)if(ps[i]=='k'){printf("there is a 'k' in the string\n");break;}if(ps[i]=='\0') printf("There is no 'k' in the st
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/24 17:01:02
指针后面有中括号表示什么main(){char st[20],*ps;int i;printf("input a string:\n");ps=st;scanf("%s",ps);for(i=0;ps[i]!='\0';i++)if(ps[i]=='k'){printf("there is a 'k' in the string\n");break;}if(ps[i]=='\0') printf("There is no 'k' in the st
指针后面有中括号表示什么
main(){
char st[20],*ps;
int i;
printf("input a string:\n");
ps=st;
scanf("%s",ps);
for(i=0;ps[i]!='\0';i++)
if(ps[i]=='k'){
printf("there is a 'k' in the string\n");
break;
}
if(ps[i]=='\0') printf("There is no 'k' in the string\n");
}
for循环中的第二个式子 为什么是for(i=0;ps[i]!='\0';i++) ps是指针变量啊?
指针后面有中括号表示什么main(){char st[20],*ps;int i;printf("input a string:\n");ps=st;scanf("%s",ps);for(i=0;ps[i]!='\0';i++)if(ps[i]=='k'){printf("there is a 'k' in the string\n");break;}if(ps[i]=='\0') printf("There is no 'k' in the st
ps[i] 里的中括号,C语言处理成运算符,ps[i] 等价于 *(ps+i),
C语言里,指针和数组关系密切.*ps, 一旦有指向地址后,就可以看成 一维数组ps[], 哪种形式便于阅读理解,就可以用哪种形式. ps[i] 等价于 *(ps+i).