</pre><pre class="csharp" name="code">/*
*Copyright(c)2014,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作者:姜甜甜
*完成日期:2014年 12月 16日
*版本号:v1.0
*/
#include <iostream>
using namespace std;
int pstrlen(char *a);
int main()
{
char s1[50]="Hello world. ";
cout<<"该字符串的长度为 "<<pstrlen(s1)<<endl;
return 0;
}
int pstrlen(char *a)
{
int i;
for(i=0; a[i]!='\0'; i++);
return i;
}
第十六周项目2-用指针玩字符串(任务三:求字符串长度)
