std::strrchr - cppreference.com
提供: cppreference.com
<tbody> </tbody>
| ヘッダ |
||
|
|
||
|
|
||
str の指すバイト文字列内の ch (char に変換後) が最後に現れる位置を探します。 終端のヌル文字は文字列の一部であるとみなされ、 '\0' を検索した場合に見つけられます。
引数
| str | - | 解析するヌル終端バイト文字列を指すポインタ |
| ch | - | 検索する文字 |
戻り値
str 内の見つかった文字を指すポインタ、またはそのような文字が見つからなかった場合はヌルポインタ。
例
#include <iostream> #include <cstring> int main() { char input[] = "/home/user/hello.c"; char* output = std::strrchr(input, '/'); if(output) std::cout << output+1 << '\n'; }
出力: