Back to index

radiance  4R0+20100331
Defines | Functions | Variables
cnt.c File Reference
#include <stdlib.h>
#include <stdio.h>

Go to the source code of this file.

Defines

#define c   i

Functions

static void loop (int *n, char *b)
int main (int argc, char *argv[])
char * tack (register char *b, register int i)

Variables

static const char RCSid [] = "$Id: cnt.c,v 1.2 2003/06/08 12:03:09 schorsch Exp $"
int n [50]
char buf [256]

Define Documentation

#define c   i

Function Documentation

static void loop ( int *  n,
char *  b 
) [static]

Definition at line 68 of file cnt.c.

{
       int  i;

       if (n[0] == 0) {
              *b = '\0';
              puts(buf);
              return;
       }
       for (i = 0; i < n[0]; i++)
              loop(n+1, tack(b, i));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 20 of file cnt.c.

{
       int  a;

       argv++; argc--;
       for (a = 0; a < argc; a++)
              n[a] = atoi(argv[a]);
       n[a] = 0;
       loop(n, buf);

       exit(0);
}

Here is the call graph for this function:

char* tack ( register char *  b,
register int  i 
)

Definition at line 38 of file cnt.c.

{
       register char  *cp;
       char  *res;

       *b++ = '\t';
       cp = b;
       if (i == 0)
              *cp++ = '0';
       else
              do {
                     *cp++ = i%10 + '0';
                     i /= 10;
              } while (i);
       res = cp--;
#define c i
       while (cp > b) {            /* reverse string */
              c = *cp;
              *cp-- = *b;
              *b++ = c;
       }
#undef c
       return(res);
}

Here is the caller graph for this function:


Variable Documentation

char buf[256]

Definition at line 15 of file cnt.c.

int n[50]

Definition at line 14 of file cnt.c.

const char RCSid[] = "$Id: cnt.c,v 1.2 2003/06/08 12:03:09 schorsch Exp $" [static]

Definition at line 2 of file cnt.c.