Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- 극장 예약 프로그램
- round()함수
- UnityHub
- C언어
- Logic Gates
- scanf 오류
- time.h
- ASCII CODE TABLE
- 반사 벡터
- 논리 게이트
- Axes
- 기호 상수
- 문자 분류
- 두 수 크기 비교 함수
- GetAxis()메서드
- 2차원 배열
- 소스코드 하이라이팅
- 프로젝트 목록 제거
- 유니티허브
- C 언어
- 전처리기 정의
- 두 값 교체하기
- 배열 사용X
- AWS Discovery Book
- 유니티
- 키입력값 받기
- Unity
- 미리 컴파일된 헤더 사용안함
- 난수 값 맞추기 게임
- 개인 정리
Archives
- Today
- Total
flrto
동적 메모리 할당 본문
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include <stdio.h> #include <stdlib.h> int main(void) { int k = 100; int i; //정적 메모리 할당 //int socre1[k] 는 불가! int score1[100]; int * score2 = NULL; //동적 메모리 할당 //C // //score2 = (int*)malloc(100 * sizeof(int)); //score2 = (int*)malloc(k * sizeof(int)); //C++// //score2 = new int[100]; //score2 = new int[k]; score2 = (int*)malloc(100 * sizeof(int)); if (score2 == NULL) { printf("동적 메모리 할당 오류\n"); exit(1); } for (i = 0; i < 100; i++) { score2[i] = 0; } //C free(score2); //C++ //delete score2; //delete[] score2; return 0; } | cs |
Comments