码迷,mamicode.com
首页 > 编程语言 > 详细

字符数组

时间:2017-12-24 20:09:12      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:返回   post   pre   数组   log   not found   include   clu   文件   

C语言中的标准函数库中的strchr()函数可以实现查找字符串中的某个字符。

头文件: #include <string.h>

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

函数说明:从左向右,在字符串s中查找字符c首次出现的位置,如果找到返回c在s中的位置(指针),否则返回NULL

#include <stdio.h>
#include <string.h>
void main()
{
    char str[]="hello world";
    char *p=strchr(str, 'w');
    if ( p )
        printf("find 'w'!);
    else
        printf("not found!");
}
相关函数:

char *strrchr(const char *s, int c); 从右向左,查找s中最右边的匹配字符位置

char *strstr(const char *s, const char *sub); //在s中查找sub子串出现的位置

字符数组

标签:返回   post   pre   数组   log   not found   include   clu   文件   

原文地址:http://www.cnblogs.com/A-Little-Nut/p/8098755.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!