#include <stdio.h>
#include <stdlib.h>
int num;
int* num_arr;
num_arr= (int*)malloc(sizeof(int));
scanf ("%d",&num_arr); //입력시 배열 주소 받게 scanf 선언
free(num_arr);
1. <stdlib.h> 헤더파일 포함시키기
2. int* 포인터 변수 선언 후 포인터에 동적할당 공간 생성
3. 실행할 명력 작성 후
4. free(포인터변수)로 해제해주어야 오류 안남.
'C언어' 카테고리의 다른 글
C언어 헤더파일 추가 #include "파일명", #ifndef #endif로 확인 (0) | 2021.08.09 |
---|---|
C언어 함수 포인터 사용법 void(* fp)(); (0) | 2021.08.09 |
c언어 #ifndef #endif headerfile (0) | 2021.08.03 |
c언어 strlen 문자열 길이 (0) | 2021.08.03 |
c언어 const define 차이 (0) | 2021.08.03 |