#include <iostream.h>
#include <stdlib.h>
void main(void)
{
unsigned int size;
int * p;
cout << "size:";
cin >> size;
p= (int *)malloc(size);
*p = 100;
cout << '\t' << *p << endl;
cout << p << endl;
p++;
cout << p << endl;
*p = 200;
cout << '\t' << *p << endl;
free(p); //제대로 반환이 되는가?
}
p 반환제대로 안되어서.
q를 하나 더 만들어서.
q= p= (int *)malloc(size);
해서
free(q)는 또 하나의 방법. 더 좋은 방법이 있음.
댓글 없음:
댓글 쓰기
국정원의 댓글 공작을 지탄합니다.