Chinaunix首页 | 论坛 | 博客
  • 博客访问: 195786
  • 博文数量: 40
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 25
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-31 10:34
文章分类
文章存档

2019年(2)

2017年(14)

2016年(8)

2015年(10)

2014年(6)

我的朋友

分类: 系统运维

2015-08-12 11:24:29

原文地址:c strchr函数实例讲解 作者:woaimaidong

原型: 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

阅读(1950) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~