간단한 초보 질문입니다... frree
글쓴이: hosik / 작성시간: 화, 2006/11/21 - 9:50오후
int i;
int *w_nodes;
w_nodes = (int *) calloc( sizeof(int) , 10 );
for( i = 0 ; i < 10 ; i++ ) {
w_nodes[i] = i + 1;
}
free( w_nodes );
visual c++ 6.0 에서 위와 같이실행하면
다른 부분의 메모리를 참조했다고 에러가 발생하는데요..
왜 그런지 모르겠습니다..
꼭 알려주시면 감사하겠습니다.
Forums:


MSDN 예제입니다.
calloc 함수의 파라미터가 바뀌었네요..
MSDN Example
/* 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--
cdecl
앗 ㅡ.ㅡ 넘 초보라서요..
이궁 넘 쪽팔리네요...ㅋㅋㅋ
아 글구 헤더파일을 malloc을 쓰니깐 해제가 잘 되내요...
정말 감사드립니다.