#include<iostream>
#include<string>
//int StrLen(char const str[])
//{
// int i;
// for(i=0;str[i] != '\0'; ++i)
// continue;
// return i;
//}
int StrLen(char const * pStr)
{
char const *p = pStr;
while(*p++)
std::cout << *p << std::endl;
;
return p -pStr - 1;
}
int main()
{
char aString[] = "the long string";
int len = StrLen(aString);
//std::string aString = "the long string";
std::cout << "The lengh of " << aString <<" is " << len << std::endl;
}
c++ 计算字符串长度
最新推荐文章于 2024-07-26 14:55:02 发布