source: CIVL/examples/languageFeatures/pointerSubtraction.cvl@ e7597e1

1.23 2.0 main test-branch
Last change on this file since e7597e1 was 3ff27cf, checked in by Manchun Zheng <zmanchun@…>, 11 years ago

updated examples since $assert/$assume has been changed to functions; fixed the model builder for the new side-effect remover.

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

  • Property mode set to 100644
File size: 564 bytes
Line 
1#include <stdlib.h>
2#include <civlc.cvh>
3
4int main(){
5 double (*p)[2];
6 double * q;
7 double a[3][2];
8 double b[3][2];
9 double **x;
10
11 p = a; //p == &a[0]
12 q = &b[0][0];
13 p += 1;
14 q += 6;
15 x = (double **)$malloc($root, sizeof(double *) * 3);
16
17 for(int i=0; i<3; i++)
18 x[i] = (double *)$malloc($root, sizeof(double) * 2);
19
20 $assert(((p - a) == 1));
21 $assert(((q - &b[0][0]) == 6));
22 $assert((&x[0] - &x[2] == -2));
23 $assert((&x[0][1] - x[0] == 1));
24 $assert((&x[3] - x == 3));
25 for(int i=0; i<3; i++)
26 $free(x[i]);
27
28 $free(x);
29 return 0;
30}
31
32
Note: See TracBrowser for help on using the repository browser.