strchr测试例程

char * strchr(char * _str, int _ch);在参数_str中查找参数_ch指定字符,找到返回字符_ch在_str中所在位置,没有找到返回NULL;
 

测试源码:

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

int main()
{
    char a[100] = "hello world";
    char *s;//定义了一个char类型的指针变量
    s = strchr(a, 'd');
    if (s != NULL)
        printf("%s\n", s);

    s = strstr(a, "wo");
    printf("%s\n", s);

    return 0;
}

测试结果:

 

猜你喜欢

转载自blog.csdn.net/zxy131072/article/details/86622435