| 1 |
extern void abort (void); |
| 2 |
extern void exit (int); |
| 3 |
extern int printf (const char *,...); |
| 4 |
|
| 5 |
struct s { struct s *n; } *p; |
| 6 |
struct s ss; |
| 7 |
#define MAX 10 |
| 8 |
struct s sss[MAX]; |
| 9 |
int count = 0; |
| 10 |
|
| 11 |
void sub( struct s *p, struct s **pp ); |
| 12 |
int look( struct s *p, struct s **pp ); |
| 13 |
|
| 14 |
int |
| 15 |
main(void) |
| 16 |
{ |
| 17 |
struct s *pp; |
| 18 |
struct s *next; |
| 19 |
int i; |
| 20 |
|
| 21 |
p = &ss; |
| 22 |
next = p; |
| 23 |
for ( i = 0; i < MAX; i++ ) { |
| 24 |
next->n = &sss[i]; |
| 25 |
next = next->n; |
| 26 |
} |
| 27 |
next->n = 0; |
| 28 |
|
| 29 |
sub( p, &pp ); |
| 30 |
if (count != MAX+2) |
| 31 |
abort (); |
| 32 |
|
| 33 |
exit( 0 ); |
| 34 |
} |
| 35 |
|
| 36 |
void sub( struct s *p, struct s **pp ) |
| 37 |
{ |
| 38 |
for ( ; look( p, pp ); ) { |
| 39 |
if ( p ) |
| 40 |
p = p->n; |
| 41 |
else |
| 42 |
break; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
int look( struct s *p, struct s **pp ) |
| 47 |
{ |
| 48 |
for ( ; p; p = p->n ) |
| 49 |
; |
| 50 |
*pp = p; |
| 51 |
count++; |
| 52 |
return( 1 ); |
| 53 |
} |