source:
CIVL/mods/dev.civl.com/examples/languageFeatures/pointerSubtractionBad2.cvl@
cb4d4f4
| Last change on this file since cb4d4f4 was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 360 bytes | |
| Line | |
|---|---|
| 1 | #include <stdlib.h> |
| 2 | #include <stddef.h> |
| 3 | #include <civlc.cvh> |
| 4 | |
| 5 | $scope root = $here; |
| 6 | |
| 7 | int main(){ |
| 8 | ptrdiff_t diff; |
| 9 | double ** x; |
| 10 | |
| 11 | x = (double **)$malloc(root, sizeof(double *) * 3); |
| 12 | for(int i=0; i<3; i++) |
| 13 | x[i] = (double *)$malloc(root, sizeof(double) * 2); |
| 14 | |
| 15 | diff = x[1] - x[0]; |
| 16 | |
| 17 | for(int i=0; i<3; i++) |
| 18 | $free(x[i]); |
| 19 | $free(x); |
| 20 | |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 |
Note:
See TracBrowser
for help on using the repository browser.
