-1
A
回答
2
從here。
返回一個指向C字符串str中第一個出現的字符的指針。
終止空字符被認爲是C字符串的一部分。因此,它也可以位於檢索指向字符串結尾的指針。
/* strchr example */
#include <stdio.h>
#include <string.h>
int main()
{
char str[] = "This is a sample string";
char * pch;
printf ("Looking for the 's' character in \"%s\"...\n",str);
pch=strchr(str,'s');
while (pch!=NULL)
{
printf ("found at %d\n",pch-str+1);
pch=strchr(pch+1,'s');
}
return 0;
}
會產生輸出
Looking for the 's' character in "This is a sample string"...
found at 4
found at 7
found at 11
found at 18
2
www.cplusplus.com是C++幫助一個非常有用的網站。如解釋功能。
對於strchr:
找到字符串字符的第一次出現將指針返回到 字符的在C字符串str第一次出現。
終止空字符被認爲是C字符串的一部分。 因此,它也可以被定位來檢索指向 結尾的指針字符串。
char* name = "[email protected]";
char* realm = strchr(name,'@');
//realm will point to "@hello.com"
0
只爲那些誰正在尋找此源代碼/實施:
char *strchr(const char *s, int c)
{
while (*s != (char)c)
if (!*s++)
return 0;
return (char *)s;
}
相關問題
- 1. 瞭解Lambda函數的工作原理
- 2. rsync壓縮及其工作原理
- 3. 什麼是VertiPaq及其工作原理
- 4. 爲了理解git的工作原理,我需要閱讀哪些內容?
- 5. 需要幫助才能瞭解異常處理的工作原理
- 6. 深入瞭解Realm的工作原理?
- 7. 需要解釋「git push」命令的工作原理
- 8. 關於編譯器及其工作原理的問題
- 9. 需要幫助瞭解連續函數
- 10. 需要了解Python中的函數
- 11. 需要了解string.count的功能()函數
- 12. 試圖瞭解這個字符串到整數函數的工作原理
- 13. 什麼是日誌收集器及其工作原理?
- 14. Javascript函數工廠代碼需要了解
- 15. 構造函數的工作原理
- 16. 需要幫助理解jQuery .val()函數
- 17. 解析工作原理
- 18. AdMob以及它的工作原理?
- 19. 如何找到在C#strchr函數
- 20. 如何設置計算雲及其工作原理?
- 21. ActionScript生命週期及其工作原理
- 22. MKI $和CVI函數的工作原理
- 23. 請解釋REDX中的組合函數的工作原理
- 24. 瞭解Apfloat及其精度
- 25. 需要幫助瞭解結構用C
- 26. 需要了解搜索欄
- 27. 需要幫助理解這個遞歸函數是如何工作的
- 28. PageRank及其數學:需要說明
- 29. 需要幫助瞭解事件在C#
- 30. 我需要了解org.hibernate.HibernateException
甚至不想想谷歌搜索裏輸入'strchr' ... – 2012-02-07 10:52:52
誰頂起這個?!哇。 – cnicutar 2012-02-07 10:53:08
您已經諮詢了[docs](http://linux.die.net/man/3/strchr),對不對? – 2012-02-07 10:53:35