C++编程题:编写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。
C++编程题:编写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。
日期:2019-06-12 11:18:52 人气:1
#include
#include
#define N 1024
int Strlen(char* str) {
int count = 0;
while (*str != '\0') {
count += 1;
++str;
}
return count;
}
void main() {
char str[N];
char* p = str;
printf("请输入str\n");
for (int i = 0, ch = '\0