E D R , A S I H C RSS

새싹-날다람쥐 6월 10일


->


char *d;

d = (char*)malloc(sizeof(char)*100);

malloc(sizeof(char)*100);

메모리 느 곳 (sizeof(char)*100)byte만 고 그 를 반다.

그리고 d는 char*기 때문 Casting (char*)malloc(sizeof(char)*100); 가 되 다.
char d [100] 다.

char *d;

d = (char*)malloc(sizeof(char)*100);

더라 d[10] 가능다.



ex)로 2 만들려면?

char **arrray, *d;


d = (char*)malloc(sizeof(char) * 100);

arrray = (char**)malloc(sizeof(d) * 100);

렇게 면 char array [100][100] 가 된다.




냐?


int temp;

char *d;

scanf("d 기를 .\n%d", temp);

d = (char*)malloc(sizeof(char) * temp);



기를 배 다.
C는 변 므로 int d[temp] 다.(무데 는 C++ 가능다.)

결론 : 메모리 .



FREE

free(d); 를 로그램 는 sizeof(char) * temp만 메모리를 OS다.

free는 가 가능다. 따라 array를 모두 free려면 for문 돌려 free(array[i]) 모두 free(array);를 다.

로그램렇게 다. 로그램 OS가 가가기 때문.

( 는 게)는 메모리 반 가 느려고 가메모리가 메모리를 때 메모리가 부 로그램 껐다 다.
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:41
Processing time 0.0118 sec