C语言 strchr

C语言 strchr

#include <string.h>
char *strchr(const char *s, int c);

功能:在字符串s中查找字母c出现的位置
参数:

  • s:字符串首地址
  • c:匹配字母(字符)

返回值:

  • 成功:返回第一次出现的c地址
  • 失败:NULL

案例

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(void)
{
    char ch[] = "hello world";
    char c = 'w';
    // 查找字符串
    char* p = strchr(ch, c);
    printf("%s
", p);

    return 0;
}
strchr 使用案例
原文地址:https://www.cnblogs.com/xiangsikai/p/12378561.html