malloc1 동적할당 malloc함수 이용 #include #include int main(void) { int i , n; printf("처리할 데이터 수는 : "); scanf("%d", &n); int* iPtr = (int*)malloc(sizeof(int)); //malloc함수 반환값은 void //사용자가 원하는 반환타입으로 설정 if(iPtr == '\0') //iPtr이 null 이면 할당 실패! { puts("동적 할당 실패!!"); } printf("\n %d개의 정수 입력 \n\n", n); for(i = 0 ; i < n; i++) { printf("[%d]번 째 정수 : ", i); scanf("%d", iPtr+i); //포인터 자체가 주소값을 }//담고있는 변수임으로 하나씩 더해줌 printf("\n %d의 정수 출력.. 2022. 7. 27. 이전 1 다음