linux 下面%m牛逼的操作

#include <unistd.h>  
#include <fcntl.h>  
#include <sys/types.h>  
#include <sys/stat.h>  
#include <fcntl.h>  
#include <errno.h>  
#include <sys/types.h>  
#include <sys/stat.h>  
#include <unistd.h>  
#include <stdio.h> 
#include <errno.h>  // errno 竟然是全局变量



int main() {  
    int fd = -1;  
    fd = open("./Makefile", O_RDONLY);  
    // close(fd);  
    if(fcntl(fd, F_GETFL))  
    {
        printf("%m  errno is %d %d\n",fd,errno);  
		errno = 3;
		printf("errno is %d\n",errno);
		printf("%m  errno is %d %d\n",fd,errno);  
		printf("fcntl success\n");
    }
	else 
	{
        printf("fcntl failure\n");
	}
    close(fd);  
	//while(1)
	//printf("file status\n");
	return 0;
}  

  

猜你喜欢

转载自www.cnblogs.com/nowroot/p/12412063.html
今日推荐