C 教程
C 標(biāo)準(zhǔn)庫 - <string.h>
C 庫函數(shù) void *memset(void *str, int c, size_t n) 復(fù)制字符 c(一個無符號字符)到參數(shù) str 所指向的字符串的前 n 個字符。
下面是 memset() 函數(shù)的聲明。
void *memset(void *str, int c, size_t n)
該值返回一個指向存儲區(qū) str 的指針。
下面的實例演示了 memset() 函數(shù)的用法。
#include <stdio.h> #include <string.h> int main () { char str[50]; strcpy(str,"This is string.h library function"); puts(str); memset(str,'$',7); puts(str); return(0); }
讓我們編譯并運行上面的程序,這將產(chǎn)生以下結(jié)果:
This is string.h library function $$$$$$$ string.h library function其他擴展