2011年度最佳C代码 - Copyleft Hardware

#include <stdio.h>
02. #include <stdlib.h>
03. #include <string.h>
04. #include <sys/fcntl.h>
05.  
06. int believe(int it, char * you)
07. {
08.     int random;
09.     int c;
10.  
11.     random = open("/dev/random", O_RDONLY);
12.     read(random, &amp;amp;c, sizeof(c));
13.     close(random);
14.  
15.     if(!strcmp(you, "people")) {
16.         printf("It doesn’t matter if you guys believe or not\n");
17.         return c;
18.     }
19.  
20.     printf("I believe!\n");
21.     return 1;
22. }
23.  
24. int main()
25. {
26.     int ret;
27.     int it;         /* you know */
28.  
29.     char * you = "people";
30.     char * I;
31.  
32.     switch(believe(it, you)) {
33.     default:
34.         ret = believe(it, I);
35.     }
36.  
37.     if(ret)
38.         printf("It's a miracle!\n");
39.  
40.     printf("It just happened!\n");
41.     return 0;
42. }

More Info

你可能感兴趣的:(代码,hardware,copyleft)