函数返回值是指针

#include<stdio.h>
#include<string.h> 

char *mystrchr(char *s,char c)
{
    while(*s)
    {
        if(*s == c)
        {
            return s;
        }
        s++;
    }
    return NULL;
}

int main()
{
    char str[100] = "hello world";
    //char* s = strchr(str,'a');
    char *s = mystrchr(str,'a');
    printf("s = %s\n",s);
    return 0;
}

 

posted @ 2019-06-11 23:42  王清河  阅读(749)  评论(0编辑  收藏  举报