+ keyue_fifo.c
/*********************************************************************************
* Copyright: (C) 2013 keyue<keyue654321@163.com>
* All rights reserved.
*
* Filename: keyue_fifo.c
* Description: This file
*
* Version: 1.0.0(09/11/2013~)
* Author: keyue<keyue654321@163.com>
* ChangeLog: 1, Release initial version on "09/11/2013 11:13:23 PM"
*
********************************************************************************/
#include "stdio.h"
#include "fcntl.h"
#include "unistd.h"
#include "sys/stat.h"
#include "stdlib.h"
#include "string.h"
char buf[] = "file content\n";
int main()
{
/*********************************************************************************
* Copyright: (C) 2013 keyue<keyue654321@163.com>
* All rights reserved.
*
* Filename: keyue_fifo.c
* Description: This file
*
* Version: 1.0.0(09/11/2013~)
* Author: keyue<keyue654321@163.com>
* ChangeLog: 1, Release initial version on "09/11/2013 11:13:23 PM"
*
********************************************************************************/
#include "stdio.h"
#include "fcntl.h"
#include "unistd.h"
#include "sys/stat.h"
#include "stdlib.h"
#include "string.h"
char buf[] = "file content\n";
int main()
{
int fd,fd1;
if ((fd = creat("file_name1",O_RDWR)) < 0)
perror("creat error");
if (write(fd,buf,20) != 20)
perror("buf write error");
dup2(fd, STDOUT_FILENO);
close(fd);
write(STDOUT_FILENO, buf, strlen(buf));
printf(fd);
exit (0);
}