source: CIVL/examples/languageFeatures/dynamicStruct.cvl@ 3b6d5b3

1.23 2.0 main test-branch
Last change on this file since 3b6d5b3 was 0d850b0, checked in by Tim Zirkel <zirkeltk@…>, 13 years ago

Added dynamically typedef'd struct example.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@166 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 334 bytes
Line 
1#include <civlc.h>
2
3void 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
23void main() {
24 $spawn f(3);
25}
Note: See TracBrowser for help on using the repository browser.