规范化风格
if(argc == 3) {
if(strncmp(argv[1], "rot", 3) == 0) {
//ret = atoi(argv[2]);
if(pthread_create(&th, NULL, rotation, argv[2]) < 0) {
printf("Rendering thread creation error\n");
}
}
} else {
char tmp = '0';
if(pthread_create(&th, NULL, rotation, &tmp) < 0) {
printf("Rendering thread creation error\n");
}
}
Fred地方
if(access(FIFO,F_OK) == -1){
mkfifo(FIFO,0777);
}
fd=open(FIFO,O_RDONLY|O_NONBLOCK);
if(fd < 0){
printf("Open fifo error!\n");
}
地方地方豆腐干
while(1){
memset(buff,'\0',100);
if((num=read(fd,buff,100))==0){
usleep(100*1000);
continue;
}
printf("read %d in fifo , it's %s",num,buff);
if(strncmp(buff, "180", 3)==0) {