c strchr函数实例讲解

简介: 原型: char *strchr(const char *s,char c); #include 查找字符串s中首次出现字符c的位置,返回首次出现c的位置的指针,如果s中不存在c则返回NULL。

原型: char *strchr(const char *s,char c);

#include<string.h>

查找字符串s中首次出现字符c的位置,返回首次出现c的位置的指针,如果s中不存在c则返回NULL

The strchr function finds the first occurrence of c instr, or it returns NULL ifc is not found. The null terminating character is included in the search.

实例讲解:

[root@bdkyr xuekun]# vim strchr_test.c

/*
 * create by xuekun
 * date 2015-7-31
 */

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

main()
{
    char *s="Golden Global View";
    char *p;
    p=strchr(s,'V');
    if(p)
        printf("%s\n",p);
    else
        printf("Not Found!\n");
    return 0;
}

[root@bdkyr xuekun]# gcc strchr_test.c -o strchr_test
[root@gateway xuekun]# ./strchr_test    
View

目录
相关文章
|
10月前
|
C语言
C 练习实例7
C 练习实例7.
59 4
|
10月前
C实例1
C实例1。
38 3
|
4月前
实例
实例。
31 3
|
7月前
|
Serverless API 异构计算
函数计算产品使用问题之gpu实例函数该如何创建
函数计算产品作为一种事件驱动的全托管计算服务,让用户能够专注于业务逻辑的编写,而无需关心底层服务器的管理与运维。你可以有效地利用函数计算产品来支撑各类应用场景,从简单的数据处理到复杂的业务逻辑,实现快速、高效、低成本的云上部署与运维。以下是一些关于使用函数计算产品的合集和要点,帮助你更好地理解和应用这一服务。
|
10月前
|
机器学习/深度学习 网络协议 Windows
C 练习实例18
C 练习实例18。
40 1
|
10月前
C 实例2
C 实例2。
46 3
|
10月前
C练习实例10
C练习实例10。
43 0
|
10月前
C练习实例9
C练习实例9
45 0
|
程序员 C++
C++程序设计函数部分(定义+实例)
C++程序设计函数部分(定义+实例)
69 0
BETWEEN.实例 2
BETWEEN.实例 2
115 4