#include <memory.h> #include <string.h> void *memset(void *buf, int c, size_t count) buf : バッファへのポインタ c : 初期化に使用する文字 count : 初期化するバイト数
#include <stdio.h>
#include <memory.h>
#include <string.h>
int main()
{
char *str = new char [30];
strcpy(str, "This is a test");
printf("初期化前 %s\n", str);
memset(str, '*', 4);
printf("初期化後 %s\n", str);
return 0;
}
初期化前 This is a test 初期化後 **** is a test
| 菅沼ホーム | 本文目次 | 演習問題解答例 | 付録目次 | 索引 |