source: CIVL/examples/languageFeatures/pointers.cvl@ 475b2d9

1.23 2.0 main test-branch
Last change on this file since 475b2d9 was 793cfc2, checked in by Tim Zirkel <zirkeltk@…>, 13 years ago

Reorganized examples and tests. Added algebra, assoc, dining, assume, and scoping examples.

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

  • Property mode set to 100644
File size: 339 bytes
RevLine 
[6543229]1#include<civlc.h>
2
[40a899c]3void passByRef(int * array) {
4 *array = 42;
5}
6
[6543229]7void main() {
8 int a;
9 int* b;
10 int c[2];
11 int* d;
[b6565a0]12 int** g;
[40a899c]13 int* f;
[b6565a0]14
[40a899c]15 f = &a;
[6543229]16 a = 1;
17 b = &a;
18 c[0] = 0;
19 c[1] = 1;
20 d = &c[1];
[b6565a0]21 g = &d;
[6543229]22 $assert *b == 1;
23 $assert *d == 1;
[b6565a0]24 $assert **g == 1;
[40a899c]25 $assert g == &d;
26 passByRef(f);
27 $assert *f == 42;
[6543229]28}
Note: See TracBrowser for help on using the repository browser.