<pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

          <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

          <p id="bbfd9"></p>

          <p id="bbfd9"><cite id="bbfd9"></cite></p>

            <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

            <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
            <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
            C語言

            C語言中strpbr()函數的用法

            時間:2025-02-17 14:09:28 C語言 我要投稿
            • 相關推薦

            C語言中strpbr()函數的用法

              C語言函數是一種函數,用來編譯C語言,下面就有小編分享C語言中strpbr()函數的用法,歡迎大家學習!

              頭文件:

              #include

              strpbrk()函數檢索兩個字符串中首個相同字符的位置,其原型為:

              char *strpbrk( char *s1, char *s2);

              【參數說明】s1、s2要檢索的兩個字符串。

              strpbrk()從s1的第一個字符向后檢索,直到',如果當前字符存在于s2中,那么返回當前字符的地址,并停止檢索。

              【返回值】如果s1、s2含有相同的字符,那么返回指向s1中第一個相同字符的指針,否則返回NULL。

              注意:strpbrk()不會對結束符'進行檢索。

              【函數示例】輸出第一個相同字符之后的內容。

              #include#includeint main(void){ char* s1 = "http://see.xidian.edu.cn/cpp/u/xitong/"; char* s2 = "see"; char* p = strpbrk(s1,s2); if(p){ printf("The result is: %sn",p); }else{ printf("Sorry!n"); } return 0;}

              輸出結果:

              The result is: see.xidian.edu.cn/cpp/u/xitong/

              DEMO:實現自己的strpbrk函數

              #include#include#include#include#pragma warning (disable:4996)char *mystrpbrk(const char *cs,const char *ct);int main(void){ char *s1="Welcome to Beijing."; char *s2="BIT"; char *s3; s3=mystrpbrk(s1,s2); printf("%sn",s3); getch(); return 0;}/*FROM 百科*/char *mystrpbrk(const char *cs,const char *ct){ const char *sc1,*sc2; for (sc1=cs;*sc1!=';sc1++) { for (sc2=ct;*sc2!=';sc2++) { if (*sc1==*sc2) { return (char *)sc1; } } } return NULL;}

              #include#include#include#include#pragma warning (disable:4996)int main(void){ char *s1="Welcome to Beijing."; char *s2="BIT"; char *p; system("cls"); p=strpbrk(s1,s2); if (p) { printf("%sn",p); } else { printf("NOT Foundn"); } p=strpbrk(s1,"i"); if (p) { printf("%sn",p); } else { printf("NOT Foundn"); } getch(); return 0;}


            【C語言中strpbr()函數的用法】相關文章:

            c語言中time函數的用法05-15

            C語言中函數的區分04-10

            c語言中getch的用法06-01

            C語言中assert用法02-26

            C語言中sscanf的用法05-09

            c語言中%s的用法07-01

            c語言中邏輯或的用法05-23

            c語言中default的用法05-26

            C語言中assert的用法06-02

                    <pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

                    <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

                    <p id="bbfd9"></p>

                    <p id="bbfd9"><cite id="bbfd9"></cite></p>

                      <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

                      <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
                      <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
                      飘沙影院