问题及代码
/*
*ALL rights reserved.
*文件名称:shiqizhouxiangmu2
*作者:李长鸿
*完成时间:2014.12.15
*问题描述:指针与字符串
*/
#include<iostream>
using namespace std;
int astrlen(char str[]);
int main()
{
char str[]="I want to become free.I love freedom!";
cout<<"字符串的长度为:"<<astrlen(str)<<endl;
return 0;
}
int astrlen(char str[])
{
int j=0;
while(*(str++)!='\0')
j++;
return j;
}