有如下程序
#include <iostream>
using namespace std;
int main(){
char str[100],*p;
cout<< "Please input a string:";
cin>>str;
p=str;
int i;
for(i=0;*p!='\0';p++, i++);
cout<<i<<endl;
return 0;}
运行这个程序时,若输入字符串为abcdefg abcd则输出结果是
7
12
13
100
发表评论