source: CIVL/examples/languageFeatures/pointerSubtractionBad2.cvl@ 5ddac35

1.23 2.0 main test-branch
Last change on this file since 5ddac35 was b4f940a, checked in by Ziqing Luo <ziqing@…>, 12 years ago

add examples for pointer subtraction

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

  • Property mode set to 100644
File size: 338 bytes
RevLine 
[b4f940a]1#include <stdlib.h>
2#include <stddef.h>
3#include <civlc.h>
4
5int main(){
6 ptrdiff_t diff;
7 double ** x;
8
9 x = (double **)$malloc($root, sizeof(double *) * 3);
10 for(int i=0; i<3; i++)
11 x[i] = (double *)$malloc($root, sizeof(double) * 2);
12
13 diff = x[1] - x[0];
14
15 for(int i=0; i<3; i++)
16 $free(x[i]);
17 $free(x);
18
19 return 0;
20}
21
22
Note: See TracBrowser for help on using the repository browser.