/* * Copyright (c) 2013, 烟台大学计算机学院 * All rights reserved. * 作 者: * 完成日期:2013 年 12月 * 版 本 号:v1.0 * 问题描述:求字符串长度 */ #include <iostream> using namespace std; int astrlen(char str1[]); int main() { char a[50]="Hello world"; char b[50]="Good moring"; int x,y; x=astrlen(a); cout<<"字符串长度为"<<x<<endl; y=astrlen(b); cout<<"字符串长度为"<<y<<endl; return 0; } int astrlen(char str1[]) { int i; for(i=0;str1[i]!='\0';i++); return i; }