st3.c
#include "defs.h"
struct S1 {
char *s;
struct S1 *s1p;
};
void swap(struct S1 *p1, struct S1 *p2)
{
char *temp = p1->s;
p1->s = p2->s;
p2->s = temp;
}
int main()
{
static struct S1 a[] = {
{ "abcd", a+1 },
{ "efgh", a+2 },
{ "ijkl", a+3 }
};
struct S1 *p[3];
int i;
for( i=0; i<3; i++) p[i] = a[i].s1p;
PRINT3(s, p[0]->s, (*p)->s, (**p).s);
swap(*p, a);
PRINT3(s, p[0]->s, (*p)->s, (*p)->s1p->s);
swap(p[0], p[0]->s1p);
PRINT3(s, p[0]->s, (*++p[0]).s, ++(*++(*p)->s1p).s);
}
p[0]->s = efgh (*p)->s = efgh (**p).s = efgh
p[0]->s = abcd (*p)->s = abcd (*p)->s1p->s = ijkl
Segmentation fault (core dumped)