/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j;
    int *a1,*a2;
    a1 = (int *)malloc(3*sizeof(int));
    for(i = 0; i < 3; i++) 
    {
        a1[i] = i + 1;
    }
    for(i = 0; i < 3; i++) 
    {
        printf("%d\n", a1[i]);
    }
    free(a1);
    a2 = (int *)malloc(2*2*sizeof(int));
    for(i = 0; i < 2; i++) 
    {
        for(j = 0; j < 2; j++) 
        {
            a2[i*2+j] = i + j+ 1;
        }
    }
    for(i = 0; i < 2; i++) 
    {
        for(j = 0; j < 2; j++) 
        {
            printf(" %d", a2[i*2+j]);
        }
        printf("\n");
    }
    free(a2);
    return EXIT_SUCCESS;
}
