Scroll to navigation

strchr(3) Library Functions Manual strchr(3)

NOM

strchr, strrchr - locate character in string

BIBLIOTHÈQUE

Bibliothèque C standard (libc-lc)

SYNOPSIS

#include <string.h>
char *strchr(const char *s, int c);
char *strrchr(const char *s, int c);

DESCRIPTION

La fonction strchr() renvoie un pointeur sur la première occurrence du caractère c dans la chaîne s.
It is equivalent to both of the following expressions:

memchr(s, c, strlen(s) + 1)
strpbrk(s, (char [2]){c, '\0'})
    

La fonction strrchr() renvoie un pointeur sur la dernière occurrence du caractère c dans la chaîne s.
It is equivalent to

memrchr(s, c, strlen(s) + 1)
    

VALEUR RENVOYÉE

Les fonctions strchr() et strrchr() renvoient un pointeur sur le caractère correspondant, ou NULL si le caractère n'a pas été trouvé. L'octet NULL final est considéré comme faisant partie de la chaîne, de telle sorte que si « \0 » est indiqué pour c, ces fonctions renvoient un pointeur sur la fin de chaîne.

ATTRIBUTS

Pour une explication des termes utilisés dans cette section, consulter attributes(7).

Interface Attribut Valeur
strchr(), strrchr() Sécurité des threads MT-Safe

NORMES

C11, POSIX.1-2008.

HISTORIQUE

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

VOIR AUSSI

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

TRADUCTION

La traduction française de cette page de manuel a été créée par Christophe Blaess <https://www.blaess.fr/christophe/>, Stéphan Rafin <stephan.rafin@laposte.net>, Thierry Vignaud <tvignaud@mandriva.com>, François Micaux, Alain Portal <aportal@univ-montp2.fr>, Jean-Philippe Guérard <fevrier@tigreraye.org>, Jean-Luc Coulon (f5ibh) <jean-luc.coulon@wanadoo.fr>, Julien Cristau <jcristau@debian.org>, Thomas Huriaux <thomas.huriaux@gmail.com>, Nicolas François <nicolas.francois@centraliens.net>, Florentin Duneau <fduneau@gmail.com>, Simon Paillard <simon.paillard@resel.enst-bretagne.fr>, Denis Barbier <barbier@debian.org>, David Prévot <david@tilapin.org>, Frédéric Hantrais <fhantrais@gmail.com> et Grégoire Scano <gregoire.scano@malloc.fr>

Cette traduction est une documentation libre ; veuillez vous reporter à la GNU General Public License version 3 concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.

Si vous découvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message à debian-l10n-french@lists.debian.org.

25 février 2026 Pages du manuel de Linux (non publiées)