view test/arrays.d @ 86:fd32135dca3e trunk

[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!! Lots of bugfixes. Added support for special foreach on strings. Added std.array, std.utf, std.ctype and std.uni to phobos. Changed all the .c files in the gen dir to .cpp (it *is* C++ after all)
author lindquist
date Sat, 03 Nov 2007 14:44:58 +0100
parents c53b6e3fe49a
children c44e6a711885
line wrap: on
line source

void integer()
{
    auto arr = new int[16];
    arr[1] = 42;
    arr[6] = 555;
    print_int(arr);
    delete arr;
}

void floating()
{
    auto arr = new float[6];
    arr[1] = 3.14159265;
    arr[3] = 1.61803399;
    print_float(arr);
    delete arr;
}

void print_int(int[] arr)
{
    printf("arr[%lu] = [", arr.length);
    for (auto i=0; i<arr.length; i++)
        printf("%d,", arr[i]);
    printf("\b]\n");
}

void print_float(float[] arr)
{
    printf("arr[%lu] = [", arr.length);
    for (auto i=0; i<arr.length; i++)
        printf("%f,", arr[i]);
    printf("\b]\n");
}

void main()
{
    integer();
    floating();
}