/* CALLOC.C: This program uses calloc to allocate space for
* 40 long integers. It initializes each element to zero.
*/
#include <stdio.h>
#include <malloc.h>
void main( void )
{
long *buffer;
buffer = (long *)calloc( 40, sizeof( long ) );
if( buffer != NULL )
printf( "Allocated 40 long integers\n" );
else
printf( "Can't allocate memory\n" );
free( buffer );
}
Output
Allocated 40 long integers
MSDN 예제입니다.
calloc 함수의 파라미터가 바뀌었네요..
MSDN Example
--
cdecl
앗 ㅡ.ㅡ 넘 초보라서요..
이궁 넘 쪽팔리네요...ㅋㅋㅋ
아 글구 헤더파일을 malloc을 쓰니깐 해제가 잘 되내요...
정말 감사드립니다.
댓글 달기