/*************************************************************************
************************************************************************/
#include <stdio.h>
#define P printf
#define D "%d\n"
int mystrlen(const char *str)
{
const char *p = str;
while (*p++);
return (p - str -1);
}
int main()
{
char *p1 = "hello";
char *p2 = " ";
char *p3 = "helloworld";
P(D, mystrlen(p1));
P(D, mystrlen(p2));
P(D, mystrlen(p3));
return 0;
> File Name: mystrlen.c
> Author: hhp
> Created Time: 2017年06月30日 星期五 17时31分33秒************************************************************************/
#include <stdio.h>
#define P printf
#define D "%d\n"
int mystrlen(const char *str)
{
const char *p = str;
while (*p++);
return (p - str -1);
}
int main()
{
char *p1 = "hello";
char *p2 = " ";
char *p3 = "helloworld";
P(D, mystrlen(p1));
P(D, mystrlen(p2));
P(D, mystrlen(p3));
return 0;
}