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