Vuser中常用的C語言函數

來源:互聯網
上載者:User

標籤:ret   const   enc   超過   tran   字元   imu   starting   span   

strchr函數與strrchr函數

 1 Action() 2 { 3 //    strchr函數用於尋找指定字元在一個字串中第1次出現的位置,然後返回指向該位置的指標; 4 //    strrchr函數使用者尋找指定字元在一個字串中最後1次出現的位置,然後返回指向該位置的指標。 5 //    文法結構 6 //        char *strchr(const char *string,int c); 7 //        char *strrchr(const char *string,int c); 8      9     10     char *string = "I‘m a young soul in this very strange world";11     char *first_a, *last_a;12     13     first_a = (char *)strchr(string, ‘a‘);14     lr_output_message("The first occurrence of a: %s", first_a);15     16     last_a = (char *)strrchr(string, ‘a‘);17     lr_output_message("The last occurrence of a: %s", last_a);18     19     return 0;20 }21 -----------------------------------------------------------------------------------22 Running Vuser...23 Starting iteration 1.24 Maximum number of concurrent connections per server: 6      [MsgId: MMSG-26989]25 Starting action Action.26 Action.c(14): The first occurrence of a: a young soul in this very strange world27 Action.c(17): The last occurrence of a: ange world28 Ending action Action.29 Ending iteration 1.30 Ending Vuser...

 

strcpy函數與strncpy函數

 1 Action() 2 { 3 //    strcpy函數是把一個字串複製到另一個字串中; 4 //    strncpy函數是把一個字串中的指定長度複製到另一個字串中,如果指定長度超過了字串長度,則會複製整個字串。 5 //    文法結構 6 //        strcpy:    char *strcpy(char *dest, const char *source); 7 //        strncpy:    char *strncpy(char *dest,const char *source, size_t n); 8 //    參數dest是目標字串,source是源字串,n是要複製的長度。 9         10     11     char test[50];12     char ntest[50];13     strcpy(test, "Copies one string to another.");14     lr_output_message("%s", test);15     16     strncpy(ntest, "Copies the first n characters of one string to another?", 30);17     lr_output_message("%s", ntest);18         19     return 0;20 }21 22 ----------------------------------------------------------------------------------23 Running Vuser...24 Starting iteration 1.25 Maximum number of concurrent connections per server: 6      [MsgId: MMSG-26989]26 Starting action Action.27 Action.c(14): Copies one string to another.28 Action.c(17): Copies the first n characters 29 Ending action Action.30 Ending iteration 1.31 Ending Vuser...

 

Vuser中常用的C語言函數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.