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