std::strrchr
來自 cppreference.com
在標頭檔案 <cstring> 中定義 |
||
const char* strrchr( const char* str, int ch ); |
||
char* strrchr( char* str, int ch ); |
||
在 str 指向的位元組字串中查詢 ch(轉換為 char 後)的最後一次出現。終止空字元被認為是字串的一部分,如果搜尋 '\0',則可以找到它。
目錄 |
[編輯] 引數
str | - | 指向要分析的以空字元結尾的位元組字串的指標 |
ch | - | 要搜尋的字元 |
[編輯] 返回值
指向 str 中找到的字元的指標,如果沒有找到該字元,則為空指標。
[編輯] 示例
執行此程式碼
#include <cstring> #include <iostream> int main() { char input[] = "/home/user/hello.c"; char* output = std::strrchr(input, '/'); if (output) std::cout << output + 1 << '\n'; }
輸出
hello.c
[編輯] 另請參閱
查詢字元的第一次出現 (函式) | |
在寬字串中查詢寬字元的最後一次出現 (函式) | |
查詢子串的最後一次出現 ( std::basic_string<CharT,Traits,Allocator> 的公共成員函式) | |
C 文件 關於 strrchr
|