c语言 11-6

1、

#include <stdio.h>

char *mach(char *s, int key)
{
    while(*s)
    {
        if(*s == key)
            return s;
        s++;
    }
    return NULL;
}

int main(void)
{
    char str[128];
    printf("str: "); scanf("%s", str);
    
    printf("result: %s\n", mach(str, 'c'));
    return 0;    
} 

 

posted @ 2021-06-02 21:45  小鲨鱼2018  阅读(43)  评论(0编辑  收藏  举报