2011年9月5日 星期一

memset

string.h 的函數 memset() 將某一記憶體區段的前 n 個字元全部設定為某一字元。
以下程式將字串 s 全部設成 'n'
#include <stdio.h>
#include <string.h>  
int main(void)
{
     char s[] = "congratulation";
     printf("%s\n", memset(s, 'n', 13));
     return 0;    
}  

沒有留言:

張貼留言