Mercurial > projects > ldc
annotate test/arrays.d @ 189:3aed08fb64f4 trunk
[svn r205] moved some local static variables used for memset and memcpy intrinsics to IrState
author | ChristianK |
---|---|
date | Sat, 10 May 2008 19:00:11 +0200 |
parents | c44e6a711885 |
children | e881c9b1c738 |
rev | line source |
---|---|
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
1
diff
changeset
|
1 extern(C) int printf(char*, ...); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
1
diff
changeset
|
2 |
1 | 3 void integer() |
4 { | |
5 auto arr = new int[16]; | |
6 arr[1] = 42; | |
7 arr[6] = 555; | |
8 print_int(arr); | |
9 delete arr; | |
10 } | |
11 | |
12 void floating() | |
13 { | |
14 auto arr = new float[6]; | |
15 arr[1] = 3.14159265; | |
16 arr[3] = 1.61803399; | |
17 print_float(arr); | |
18 delete arr; | |
19 } | |
20 | |
21 void print_int(int[] arr) | |
22 { | |
23 printf("arr[%lu] = [", arr.length); | |
24 for (auto i=0; i<arr.length; i++) | |
25 printf("%d,", arr[i]); | |
26 printf("\b]\n"); | |
27 } | |
28 | |
29 void print_float(float[] arr) | |
30 { | |
31 printf("arr[%lu] = [", arr.length); | |
32 for (auto i=0; i<arr.length; i++) | |
33 printf("%f,", arr[i]); | |
34 printf("\b]\n"); | |
35 } | |
36 | |
37 void main() | |
38 { | |
39 integer(); | |
40 floating(); | |
41 } |