Waitrud Weber’s blog

things and reminders for memories

linux: memorization is stable, we can think. threre is no any other way.

#include 
#include 

#include "Axex.h"

int main () {

        //x Axex** axex = nullptr;
        Axex** axex = NULL;

        axex = (Axex**) malloc (sizeof(Axex*) * 10);
        for( int i=0; i<10; i++ ) {
                axex[i] = (Axex*) malloc (sizeof(Axex) * 10);
                printf("axe[%d]=%d\n", i, axex[i]);
        }
        printf("realloc may be going.\n");
        for( int i=0; i<10; i++ ) {
                axex[i] = new Axex ();
                printf("axe[%d]=%d\n", i, axex[i]);
        }

        return 0;
}

The result on the linux is the below.

> gcc -c main.cpp
> gcc -c Axex.cpp
> gcc main.o Axex.o -o main_002.exe

./main_002.exe
axe[0]=163975224
axe[1]=163975240
axe[2]=163975256
axe[3]=163975272
axe[4]=163975288
axe[5]=163975304
axe[6]=163975320
axe[7]=163975336
axe[8]=163975352
axe[9]=163975368
realloc may be going.
axe[0]=163975384
axe[1]=163975400
axe[2]=163975416
axe[3]=163975432
axe[4]=163975448
axe[5]=163975464
axe[6]=163975480
axe[7]=163975496
axe[8]=163975512
axe[9]=163975528