source:
CIVL/examples/languageFeatures/malloc2d.cvl@
38b7d06
| Last change on this file since 38b7d06 was 8fa5a7b, checked in by , 13 years ago | |
|---|---|
|
|
| File size: 263 bytes | |
| Line | |
|---|---|
| 1 | #include <civlc.h> |
| 2 | #define N 5; |
| 3 | #define M 8; |
| 4 | |
| 5 | void main() { |
| 6 | $heap h; |
| 7 | double **p = (double **) $malloc(&h, N*sizeof(double *)); |
| 8 | |
| 9 | for (int i = 0; i < M; i++) { |
| 10 | p[i] = (double *) $malloc(&h |
| 11 | } |
| 12 | |
| 13 | p[4]=3.14; |
| 14 | $assert(p[4]==3.14); |
| 15 | $free(&h, p); |
| 16 | } |
Note:
See TracBrowser
for help on using the repository browser.
