Files
ldc/test/arrays.d
Tomas Lindquist Olsen c380f43929 [svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
Changed: removed the crappy realloc based dynamic memory runtime and started moving over to DMD style runtime support, part of moving to real GC.
Fixed: dynamic arrays now use GC runtime for allocating memory.
Fixed: new expression now use GC for allocating memory.
Changed: revamped the dynamic array support routines related to dynamic memory.
Fixed: assertions no longer create exsessive allocas.
Changed: misc. minor cleanups.
2008-05-13 14:42:09 +02:00

44 lines
722 B
D

module arrays;
extern(C) int printf(char*, ...);
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();
}