char *strpbrk(const char *string1, const char *string2);
IBM 說明
The strpbrk() function locates the first occurrence in the string pointed to by string1 of any character from the string pointed to by string2.
我的理解:strpbrk函式會回傳string2中的第一個字元,第一次出現在string1中的指標
- int main(void)
- {
- char *string1 = "Test string1 for learn";
- char *chars = "le";
- char *result;
- result = strpbrk(string1, chars);
- printf("The first occurrence of any of the characters \"%s\" in "
- "\"%s\" is \"%s\"\n", chars, string1, result);
- }
執行結果
參考資料
- int main(void)
- {
- char *string1 = "Test string1 for learn";
- char *chars = "le";
- char *result;
- result = strpbrk(string1, chars);
- printf("The first occurrence of any of the characters \"%s\" in "
- "\"%s\" is \"%s\"\n", chars, string1, result);
- }
https://zh.m.wikipedia.org/zh-tw/String.h#%E5%87%BD%E6%95%B0
https://www.ibm.com/docs/en/i/7.1?topic=functions-strpbrk-find-characters-in-string
沒有留言:
發佈留言