File: test.c

package info (click to toggle)
nana 2.5-12
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 1,748 kB
  • ctags: 373
  • sloc: sh: 2,862; ansic: 1,546; makefile: 189; tcl: 48; lisp: 39
file content (59 lines) | stat: -rw-r--r-- 1,487 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * test.c - used for testing our macros
 *
 *    nana - improved support for invariant checking and logging
 *    Copyright (C) 1996  P.J.Maker <pjm@gnu.org>
 * 
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Library General Public
 *    License as published by the Free Software Foundation; either
 *    version 2 of the License, or (at your option) any later version.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Library General Public License for more details.
 * 
 *    You should have received a copy of the GNU Library General Public
 *    License along with this library; if not, write to the Free
 *    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * Header: /home/pjm/cvs/nana/gdb/test.c,v 1.3 1998/06/22 07:06:03 pjm Exp  
 */


#include <stdio.h>
#include <math.h>

int twice(int i) {
     i = i * 2;
     
     return i ;
}

int abs(int i) {
     if(i >= 0) {
	  return i;
     } else {
	  return -i;
     }
}

int distance(int i, int j) {
     return abs(i - j);
}

main() {
     setbuf(stdout, NULL); /* disable buffering */

     printf("** main()\n");
     printf("** 1: %d\n", distance(1,-5));
     printf("** 2: %d\n", distance(twice(1),-5));
     printf("** 3: %d\n", distance(3,-5));
}