view test/arrays.d @ 109:5ab8e92611f9 trunk

[svn r113] Added initial support for associative arrays (AAs). Fixed some problems with the string runtime support functions. Fixed initialization of array of structs. Fixed slice assignment where LHS is slice but RHS is dynamic array. Fixed problems with result of assignment expressions. Fixed foreach problems with key type mismatches.
author lindquist
date Wed, 21 Nov 2007 04:13:15 +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();
}