Last active
May 29, 2021 13:53
-
-
Save itmir913/ab11f77f252ecbe6629ef277a9555e15 to your computer and use it in GitHub Desktop.
[1차원 배열 동적할당] C언어 동적 배열 할당 #배열 #동적할당
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| int *createArray(int num) { | |
| int *arr = (int *) malloc(sizeof(int) * num); | |
| for (int i = 0; i < num; i++) { | |
| *(arr + i) = i; | |
| } | |
| return arr; | |
| } | |
| int main(void) { | |
| int *arr = createArray(10); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment