source:
CIVL/examples/languageFeatures/dynamicStruct.cvl@
3b6d5b3
| Last change on this file since 3b6d5b3 was 0d850b0, checked in by , 13 years ago | |
|---|---|
|
|
| File size: 334 bytes | |
| Rev | Line | |
|---|---|---|
| [0d850b0] | 1 | #include <civlc.h> |
| 2 | ||
| 3 | void f(int n) { | |
| 4 | int sum; | |
| 5 | typedef struct foo { | |
| 6 | int sum; | |
| 7 | int bar[n]; | |
| 8 | } foo; | |
| 9 | ||
| 10 | foo s; | |
| 11 | sum = (n * (n + 1)) / 2; | |
| 12 | if (n > 1) { | |
| 13 | $spawn f(n-1); | |
| 14 | } | |
| 15 | s.sum = 0; | |
| 16 | for (int i = 0; i < n; i++) { | |
| 17 | s.bar[i] = i; | |
| 18 | s.sum += s.bar[i]; | |
| 19 | } | |
| 20 | $assert sum == s.sum; | |
| 21 | } | |
| 22 | ||
| 23 | void main() { | |
| 24 | $spawn f(3); | |
| 25 | } |
Note:
See TracBrowser
for help on using the repository browser.
