原型:char *strrchr(const char *str, char c); http://blog.csdn.net/hgj125073/article/details/8443912
2015-09-08 15:29
573 查看
【FROM MSDN && 百科】
原型:char *strrchr(const char *str, char c);
#include<string.h>
找一个字符c在另一个字符串str中末次出现的位置(也就是从str的右侧开始查找字符c首次出现的位置),并返回从字符串中的这个位置起,一直到字符串结束的所有字符。如果未能找到指定字符,那么函数将返回NULL。
The strrchr function finds the last occurrence of c (converted to char)
in str. The search includes the terminating null character.
DEMO:
[cpp] view
plaincopy
#include <stdio.h>
#include <conio.h>
#include <string.h>
#pragma warning (disable:4996)
int main(void)
{
char string[20];
char *ptr;
char c='r';
strcpy(string,"There are two rings");
ptr=strrchr(string,c);
//ptr=strchr(string,c);
if (ptr!=NULL)
{
printf("The character %c is at position:%s\n",c,ptr);
}
else
{
printf("The character was not found\n");
}
getch();
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原型:char *strrchr(const char *str, char c);
#include<string.h>
找一个字符c在另一个字符串str中末次出现的位置(也就是从str的右侧开始查找字符c首次出现的位置),并返回从字符串中的这个位置起,一直到字符串结束的所有字符。如果未能找到指定字符,那么函数将返回NULL。
The strrchr function finds the last occurrence of c (converted to char)
in str. The search includes the terminating null character.
DEMO:
[cpp] view
plaincopy
#include <stdio.h>
#include <conio.h>
#include <string.h>
#pragma warning (disable:4996)
int main(void)
{
char string[20];
char *ptr;
char c='r';
strcpy(string,"There are two rings");
ptr=strrchr(string,c);
//ptr=strchr(string,c);
if (ptr!=NULL)
{
printf("The character %c is at position:%s\n",c,ptr);
}
else
{
printf("The character was not found\n");
}
getch();
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
相关文章推荐
- expect中的close,wait,exit,return
- ASMCMD fails to start on module libnnz10.so, permission denied
- 行为型模式:责任链模式(Chain of Responsibility Pattern)
- CMAKE_GENERATOR_TOOLSET and CMAKE_TOOLCHAIN_FILE
- 解决airserver在Windows下安装失败的问题
- http://elinux.org/Main_Page
- [YARN] 2.2 GB of 2.1 GB virtual memory used. Killing container.
- STL map,vector和pair的混合应用
- FOXMAIL无法响应
- LeetCode 219. Contains Duplicate II
- Customizing AIX Prompt
- 算法杂货铺——分类算法之朴素贝叶斯分类(Naive Bayesian classification)
- tail命令和head命令查询文件指定行数
- 使用UltraISO制作U盘启动盘
- Liunx 下装openoffice 乱码解决__http://wenku.baidu.com/link?url=3uaBXBwPt_ewQSZEV1vnyhaFrB8Pf7Z-VYJDGLnFvUM
- win8配置最新版flashdevelop v2和 sdk4.6+air18 配置系统未能初始化flashplayer等 解决配置方案
- 【Django】 发邮件 email
- git clone操作出现fatal:index-pack failed错误解决方案
- Latex Tools在OSX EI Captain无法编译的问题
- CPaintDC CDC