]> pd.if.org Git - lice/blob - tests/pointer.c
autocommit for files dated 2014-11-17 20:13:36
[lice] / tests / pointer.c
1 // pointers
2
3 int main(void) {
4     int   a   = 1024;
5     int  *b   = &a;
6     char *c   = "hi";
7     char *d   = "hi" + 1;
8     char  e[] = "abc";
9     char *f   = e + 2;
10     char  g[] = "abc";
11
12     *g = 32;
13     expecti(*b, 1024);
14     expecti(*c, 'h');
15     expecti(*d, 'i');
16     expecti(*f, 'c');
17     expecti(*g, 32);
18
19     int aa[] = { 1, 2, 3 };
20     int *p = aa;
21     expecti(*p, 1); p++;
22     expecti(*p, 2); p++;
23     expecti(*p, 3);
24     expecti(*p, 3); p--;
25     expecti(*p, 2); p--;
26     expecti(*p, 1);
27
28     return 0;
29 }