strchr

Section: C Library Functions (3)
Updated: 2026-02-25
Index JM Home Page roff page
 

名前

strchr, strrchr - locate character in string  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#include <string.h>

char *strchr(const char *s, int c);
char *strrchr(const char *s, int c);
 

説明

strchr()
strchr() 関数は、文字列 s 中に最初に文字 c が現れた位置へのポインターを返す。
It is equivalent to both of the following expressions:
memchr(s, c, strlen(s) + 1)
strpbrk(s, (char [2]){c, '\0'})
strrchr()
strrchr() 関数は、文字列 s 中に最後に文字 c が現れた位置へのポインターを返す。
It is equivalent to
memrchr(s, c, strlen(s) + 1)
 

返り値

The strchr() and strrchr() functions return a pointer to the matched character or NULL if the character is not found. The terminating null byte is considered part of the string, so that if c is specified as '\0', these functions return a pointer to the terminator.  

属性

この節で使用されている用語の説明については、 attributes(7) を参照。
インターフェース属性値
strchr(), strrchr() Thread safetyMT-Safe
 

標準規格

C11, POSIX.1-2008.  

歴史

POSIX.1-2001, C89, SVr4, 4.3BSD.  

関連項目

memchr(3), string(3), strchrnul(3), strlen(3), strnul(3), strpbrk(3), strsep(3), strspn(3), strstr(3), strtok(3), wcschr(3), wcsrchr(3)


 

Index

名前
ライブラリ
書式
説明
返り値
属性
標準規格
歴史
関連項目

This document was created by man2html, using the manual pages.