* gdb.base/help.exp: Replace most of docstrings for "info signals"
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / run.c
CommitLineData
ef44eed1
SS
1/*
2 * This simple classical example of recursion is useful for
3 * testing stack backtraces and such.
4 */
5
6#ifdef vxworks
7# include <vxWorks.h>
8# include <stdioLib.h>
9
10/* VxWorks does not supply atoi. */
11static int
12atoi (z)
13 char *z;
14{
15 int i = 0;
16
17 while (*z >= '0' && *z <= '9')
18 i = i * 10 + (*z++ - '0');
19 return i;
20}
21
22/* I don't know of any way to pass an array to VxWorks. This function
23 can be called directly from gdb. */
24
25vxmain (arg)
26char *arg;
27{
28 char *argv[2];
29
30 argv[0] = "";
31 argv[1] = arg;
32 main (2, argv, (char **) 0);
33}
34
35#else /* ! vxworks */
36# include <stdio.h>
37#endif /* ! vxworks */
38
39main (argc, argv, envp)
40int argc;
41char *argv[], **envp;
42{
43 if (argc != 2) {
44 printf ("usage: factorial <number>\n");
45 return 1;
46 } else {
47 printf ("%d\n", factorial (atoi (argv[1])));
48 }
49 return 0;
50}
51
52int factorial (value)
53int value;
54{
55 if (value > 1) {
56 value *= factorial (value - 1);
57 }
58 return (value);
59}
This page took 0.049318 seconds and 4 git commands to generate.