Desc :
Source Code :
#include <stdio.h>
#include <string.h>
#include <malloc.h>
void main()
{
char *pbuf;
pbuf = malloc(100 * 10000);
if (pbuf)
{
memset(pbuf, 0, 100 * 1000); // 할당된 메모리 버퍼를 null로 채움
strcpy(&pbuf[0], "string");
puts(&pbuf[0]); // 0위치부터 문자열 출력
free(pbuf);
}
}
Result :
'C' 카테고리의 다른 글
[C] 232 void형 포인터를 사용한 다양한 배열 복사하기 (1) | 2021.02.07 |
---|---|
[C] 231 메모리 100MB 할당 (1) | 2021.02.07 |
[C] 229 문자열에 대한 임시 저장소 만들기 strdup (1) | 2021.02.07 |
[C] 228 문자열 null로 채우기 (1) | 2021.02.07 |
[C] 227 문자열 첫글자를 대문자로 변환하기 isalpha (1) | 2021.02.07 |