strchr函数
来源:互联网 发布:mac 推出硬盘 编辑:程序博客网 时间:2024/06/05 02:43
strchr函数
分类:
版权声明:本文为博主原创文章,未经博主允许不得转载。
函数原型:extern char *strchr(char *str,char character)
参数说明:str为一个字符串的指针,character为一个待查找字符。
所在库名:#include <string.h>
函数功能:从字符串str中寻找字符character第一次出现的位置。
返回说明:返回指向第一次出现字符character位置的指针,如果没找到则返回NULL。
其它说明:还有一种格式char *strchr( const char *string, int c ),这里字符串是以int型给出的。
实例:
#include<string.h>
#include<stdio.h>
int main()
...{
char *str="Hello,I am sky2098,I liking programing!";
char character='k' ; //指定一个字符
char *strtemp;
strtemp=strchr(str,character);
if(strtemp!=NULL)
...{
printf("%s ",strtemp);
}
else
...{
printf("can not find %c !",strtemp);
}
return 0;
}
#include<stdio.h>
int main()
...{
char *str="Hello,I am sky2098,I liking programing!";
char character='k' ; //指定一个字符
char *strtemp;
strtemp=strchr(str,character);
if(strtemp!=NULL)
...{
printf("%s ",strtemp);
}
else
...{
printf("can not find %c !",strtemp);
}
return 0;
}
在VC++ 6.0编译运行:
注意返回字符串包含我们character字符。
我们把下面定义:
char character='k' ; //指定一个字符
改写成:
int character='k' ; //指定一个字符
也同样能够实现。阅读全文
0 0
- strchr函数
- strchr() 函数
- strchr函数
- strchr函数
- strchr函数
- strchr函数
- strchr 函数
- strchr函数
- strchr函数
- strchr函数
- strchr函数
- strchr函数
- strchr函数
- 函数strchr
- strchr函数
- strchr函数
- strchr函数
- strchr函数
- java整合SSM注解开发org.springframework.beans.factory.NoSuchBeanDefinitionException
- 用size命令分析linux程序内存段的分布
- 第二章 Spring MVC入门 —— 跟开涛学SpringMVC
- leetcode 287. Find the Duplicate Number 双指针 + 快慢指针
- TCP三次握手/四次挥手
- strchr函数
- js删除不用的数组中的数字
- 腾讯FPGA云-背后的技术
- python问题
- Python的编码注释# -*- coding:utf-8 -*-
- IntelliJ Idea 2017 注册码 免费激活方法
- 可视化tensorflow中间层
- Linux SPI总线设备驱动模型详解
- 给定一个二叉树和其中的一个节点,求中序遍历这个节点的下一个节点