Chinaunix首页 | 论坛 | 博客
  • 博客访问: 212852
  • 博文数量: 70
  • 博客积分: 2050
  • 博客等级: 大尉
  • 技术积分: 700
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-15 21:42
文章分类

全部博文(70)

文章存档

2013年(1)

2011年(5)

2010年(3)

2009年(9)

2008年(17)

2007年(6)

2006年(29)

我的朋友

分类: C/C++

2006-08-02 16:37:59

#include 
#include 

static void
file_cleanup(int *fd)
{
    printf("close file descriptor.\n");
    if (*fd >= 0)
        close(*fd);
}

int
main(void)
{
    int fd __attribute__ ((__cleanup__(file_cleanup)));
    char *msg = "hello, world.\n";

    if ((fd = open("/dev/tty"O_RDWR)) < 0)
    {
        perror("/dev/tty");
        return 1;
    }

    write(fdmsgstrlen(msg));

    return 0;
}
阅读(1102) | 评论(0) | 转发(0) |
0

上一篇:读取纯真IP数据库

下一篇:大数数制转换

给主人留下些什么吧!~~