인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

Learning data structures and various examples in C

C language basic grammar review - arrays, pointers, strings, dynamic memory allocation

자료구조 1강, 코드, array --> tmp 할당, 방 4개에서 방 8개로 이사함 ㅅㅅ

Written on

·

47

0

#include <stdio.h>

#include <stdlib.h>

int main(void)

{

int* array = (int*)malloc(4*sizeof(int));

array[0] = 1;

array[1] = 2;

array[2] = 3;

int* tmp = (int*)malloc(8 * sizeof(int));

int i;

for (i = 0; i < 4; i++)

tmp[i] = array[i];

array = tmp;

array[3] = 4;

array[4] = 5;

printf("%d\n", array[3]);

}

c

Answer

This question is waiting for answers
Be the first to answer!