首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::strrchr

Defined in header <cstring>

const char* strrchr( const char* str, int ch );

char* strrchr( char* str, int ch );

查找最后一次出现的ch转换为char所指向的字节字符串中的%29str.终止空字符被视为字符串的一部分,如果搜索'\0'...

参数

str

-

pointer to the null-terminated byte string to be analyzed

ch

-

character to search for

返回值

中找到的字符的指针。str,如果找不到这样的字符,则为空指针。

二次

代码语言:javascript
复制
#include <iostream>
#include <cstring>
 
int main()
{
    char input[] = "/home/user/hello.c";
    char* output = std::strrchr(input, '/');
    if(output)
        std::cout << output+1 << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
hello.c

二次

另见

strchr

finds the first occurrence of a character (function)

wcsrchr

finds the last occurrence of a wide character in a wide string (function)

rfind

find the last occurrence of a substring (public member function of std::basic_string)

c strrchr文件

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券