1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | #include <stdlib.h>
|
|---|
| 2 | #include <civlc.cvh>
|
|---|
| 3 |
|
|---|
| 4 | int 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.