[C/C++笔面试]自己实现Strlen,my_strlen最优解

Posted zxnsirius

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[C/C++笔面试]自己实现Strlen,my_strlen最优解相关的知识,希望对你有一定的参考价值。

/*********************************************************
-  Copyright (C): 2016
-  File name    : my_strlen.c
-  Author       : - Zxn -
-  Date         : 2016年08月27日 星期六 15时13分55秒
-  Description  : 

*  *******************************************************/
#include <stdio.h>
#include <string.h>
#include <assert.h>

int my_strlen1(const char *str)

    int len = 0;
    assert(str != NULL);
    //用临时变量做统计,但是每次循环都要++两次
    while (*str++ != 

以上是关于[C/C++笔面试]自己实现Strlen,my_strlen最优解的主要内容,如果未能解决你的问题,请参考以下文章