2011年度最佳C代码

2011年度最佳C代码

2011-08-05. Category & Tags: Others Others

  
#include stdio.h  
#include stdlib.h  
#include string.h  
#include sys/fcntl.h

int believe(int it, char * you)  
{
	int random;  
	int c;

	random = open("/dev/random", O_RDONLY);  
	read(random, amp;c, sizeof(c));

	if(!strcmp(you, "people")) {
		printf("It doesn’t matter if you guys believe or notn");  
		close(random);  
		return c;  
	}

	close(random);

	printf("I believe!n");  
	return 1;  
}

int main()  
{
	int ret;  
	int it;			/* you know */

	char * you = "people";  
	char * I;

	switch(believe(it, you)) {
	default:  
		ret = believe(it, I);  
	}

	if(ret)  
		printf("It's a miracle!n");

	printf("It just happened!n");  
	return 0;  
}

More Info