Run ID:187

提交时间:2022-07-21 18:03:18

#include<iostream> #include<cstring> using namespace std; int s(char *p) //定义字符指针p { int cnt=0; while(*p!='\0') //什么时候结束循环,在一段字符串中是以'\0'结束的 { cnt++; //计算有多少个字符的 p++; //移位 } return cnt; } int main(){ char a[1001]; cin>>a; cout<<s(a); return 0; }