//模拟实现strlen #include#include #include size_t mystrlen(const char* str) { //if (str = NULL) { // return 0; //} assert(str != NULL); size_t len = 0; while(str[len] != ' ') { len++; } return len; } int main() { printf("%dn", mystrlen("acde")); return 0; }
实现结果:



