Realize their strlen

By MSDN query that
Here Insert Picture Description
it functions as follows;

#define	_CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
    unsigned int Mystrlen(const char *string)
    {
    	assret(string != NULL);//断言
    	int count = 0;
    	while (*string != '\0')
    	{
    		count++;
    		string++;
    	}
    	return count;
    }
    int main()
    {
    	char* str = "belongAL";
    	int len = Mystrlen(str);
    	printf("%d\n", len);
    	system("pause");
    	return 0;
    }

Guess you like

Origin blog.csdn.net/belongHWL/article/details/91354089