memcpy memset memmove

來源:互聯網
上載者:User

       我覺得這些函數 fill()  fill_n()  strcpy()  strcpy() 大家都很熟悉,於是從百科貼幾個不常用的c函數,全當做自己學習。

       

       1. memcpy()

        原型:extern void *memcpy(void *dest, void *src, unsigned int count);

  用法:#include <string.h>

  功能:由src所指記憶體地區複製count個位元組到dest所指記憶體地區。

  說明:src和dest所指記憶體地區不能重疊,函數返回指向dest的指標。

  注意:與strcpy相比,memcpy並不是遇到'/0'就結束,而是一定會拷貝完n個位元組。

      

       2.  void *memset(void *s, int i, unsigned n)

       將s所指向的某一塊記憶體中的每個位元組的內容全部設定為ch指定的ASCII值,塊的大小由第三個參數指定,這個函數通常為新申請的記憶體做初始化工作, 其傳回值為指向S的指標。

      

       3.  memmove

      原型:extern void *memmove(void *dest, const void *src, unsigned int count);

  用法:#include <string.h>

  功能:由src所指記憶體地區複製count個位元組到dest所指記憶體地區。

  說明:src和dest所指記憶體地區可以重疊,但複製後src內容會被更改。函數返回指向dest的指標。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.