playing with c에서 챕터13 동적할당에 나오는 연습문제 내용인데


#include <stdio.h>

#include <malloc.h>

#pragma warning(disable:4996)

 

 

int main(void)

{

        int count = 0, max = 0;

        int* ptr = &count;

        while (ptr != NULL)

        {

               ptr = (int*)malloc(1024);

               count++;

        }

        max = count* (1024);

        printf("%d byte\n", max);

       

        return 0;

 

}


이코드를 돌리면 1956311040byte가 나오고


malloc의 할당단위를 4로 하면 1034684416 이 나오는데


이수치를 비교해서 이런결과가 나온값을 쓰라는데 왜 이렇게 나오는지 이유도 모르겠고 비교도 못하겠네요 ㅠㅠ


두번째는 reallco을 써서 크기를 다시 측정해보는건데 어떻게 해야할까요?