strlen实现 模拟实现库函数strlen

strlen实现
模拟实现库函数strlen

#include<stdio.h>
#include<assert.h>
//模拟实现库函数strlen
int my_strlen(const char* str){
	int count = 0;
	assert(str != NULL);
	while (*str != '\0'){
		count++;
		str++;
	}
	return count;
}


int main(){

	char arr[] = "abcdefg";
	printf("%d\n", my_strlen(arr));

	return 0;
}
发布了54 篇原创文章 · 获赞 28 · 访问量 7273

猜你喜欢

转载自blog.csdn.net/jiangkun0331/article/details/105329211