열렬히.뛰기

ft_strpbrk

école 42 > exam02 > exam02 : part2 > ft_strpbrk

문제

c
Assignment name	: ft_strpbrk
Expected files	: ft_strpbrk.c
Allowed functions: None
---------------------------------------------------------------

Reproduce exactly the behavior of the function strpbrk
(man strpbrk).

The function should be prototyped as follows:

char	*ft_strpbrk(const char *s1, const char *s2);

공략법

  • strpbrk : String Pointer Break 라는 뜻

함수 설명

c
#include <string.h>  // C++ 에서는 <cstring>

const char* strpbrk(const char* str1, const char* str2);
char* strpbrk(char* str1, const char* str2);

문자열에서 다른 문자열에 들어 있는 문자들을 검색어로 생각하여 찾는다.

이 때, 가장 첫번째로 일치되는 문자를 가리키는 포인터를 반환한다.

만일 일치되는 것이 없다면 NULL 을 반환하게 된다.

또한 이 함수는 문자열의 NULL 종료 문자는 문자열에 포함되어 있지 않다고 생각한다.