- cb
The c beautifier.
$ cat lotto.c
#include <time.h>
main() { int n[51]; int i,j,k,t; long timval;
(void) time(&timval); srand(timval); for(i=0;i<51;i++) n[i]=0;
i=6; while(i) { k=rand()%50+1; if(n[k]) continue; n[k]++; i--; }
for(i=0;i<51;i++) if (n[i]) printf("%02d\t",i); printf("\n"); }
$ cb lotto.c
#include <time.h>
main() {
int n[51];
int i,j,k,t;
long timval;
(void) time(&timval);
srand(timval);
for(i=0;i<51;i++) n[i]=0;
i=6;
while(i) {
k=rand()%50+1;
if(n[k]) continue;
n[k]++;
i--;
}
for(i=0;i<51;i++) if (n[i]) printf("%02d\t",i);
printf("\n");
}
- cflow
cflow generates a flow graph fo the fucntions..
$ cflow animal.c
1 main: int(), <animal.c 15>
2 printf: <>
3 yes: int(), <animal.c 55>
4 gensis: int(), <animal.c 28>
5 make_node: struct*(), <animal.c 46>
6 malloc: <>
7 strcpy: <>
8 endgame: int(), <animal.c 63>
9 printf: 2
10 yes: 3
11 gets: <>
12 make_node: 5
13 guess: int(), <animal.c 33>
14 printf: 2
15 yes: 3
16 endgame: 8
17 guess: 13
- lint
lint checks for bug or nonportable use of C.
$ lint animal.c
animal.c(25): warning: main() returns random value to invocation environment
animal.c(58): warning: b set but not used in function yes
malloc value used inconsistently llib-lc(441) :: animal.c(48)
malloc value declared inconsistently llib-lc(441) :: animal.c(48)
printf returns value which is always ignored
strcpy returns value which is always ignored
gets returns value which is always ignored
- prof
$ cc -p lotto.c
$ a.out
01 14 18 27 30 33
cochise : prof
%time cumsecs #call ms/call name
100.0 0.01 7 1.43 _printf
0.0 0.01 7 0.00 __doprnt
0.0 0.01 1 0.00 __findbuf
0.0 0.01 18 0.00 _strlen
0.0 0.01 1 0.00 _time
0.0 0.01 1 0.00 _write