码迷,mamicode.com
首页 > 其他好文 > 详细

函数返回值是指针

时间:2019-06-12 00:55:50      阅读:75      评论:0      收藏:0      [点我收藏+]

标签:print   turn   char*   color   ret   hello   char   return   har   

#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;
}

 

函数返回值是指针

标签:print   turn   char*   color   ret   hello   char   return   har   

原文地址:https://www.cnblogs.com/wanghao-boke/p/11007002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!