|   Systemnahe Programmierung in C: Puzzle |  | 
 
       
      |    1#include <stdio.h>    2    3struct S1    4{    5  char *s;    6  struct S1 *s1p;    7};    8    9struct S1 a[] = { {"abcd", a + 1},   10                  {"efgh", a + 2},   11                  {"ijkl", a}   12};   13   14struct S1 *p[3];   15   16void   17swap (struct S1 *p1, struct S1 *p2)   18{   19  char *tmp;   20  tmp   = p1->s;   21  p1->s = p2->s;   22  p2->s = tmp;   23}   24   25int   26main (void)   27{   28  char *f = "%s %s %s\n";   29   30  {   31    int i;   32    for (i = 0; i < 3; i++)   33      p[i] = a[i].s1p;   34  }   35   36  printf (f, p[0]->s, (*p)->s, (**p).s);   37   38  printf (f, p[1]->s, p[0]->s1p->s, p[2]->s1p->s1p->s);   39   40  swap (*p, a);   41   42  printf (f, p[2]->s1p->s, p[2]->s, p[1]->s);   43   44  return 0;   45} | 
 
       
      | 
 | 
 
       
      | 
 | 
 
      | Letzte Änderung: 11.01.2007 | © Prof. Dr. Uwe Schmidt  |