Thread: redirecting stdout

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    10

    redirecting stdout

    I'm trying to redirect stdout in the case of the append operator, ">>". When trying to open the correct file descriptor using the following line I get an error.

    fd[1] = open(output_file, O_WRONLY|O_CREAT|O_APPEND, 0666);

    When I try to compile my program I get these errors:

    'O_WRONLY' undeclared (first use in this function)
    'O_CREAT' undeclared (first use in this function)
    'O_APPEND' undeclared (first use in this function)

    I have included 'unistd.h' and 'fcnt1.h' since I thought those were the two header files I needed in order for the above line of code to work. But I don't really know why those file descriptor flags don't get recognized. Anyone have any suggestions?

  2. #2
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    you forgot to include this library(or at least mispelled it)
    Code:
           #include <fcntl.h>
    You have fcnt1<-that is a 1(one) not fcntl <-that is an l(el)
    Last edited by linuxdude; 04-21-2004 at 09:34 PM.

  3. #3
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    if it helps, fcntl.h stands for FileControl.h.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Redirecting stdout to socket
    By rancor in forum C Programming
    Replies: 9
    Last Post: 10-18-2008, 05:18 AM
  2. redirecting stdout
    By ichijoji in forum C++ Programming
    Replies: 2
    Last Post: 08-15-2006, 09:20 PM
  3. Problems with switch()
    By duvernais28 in forum C Programming
    Replies: 13
    Last Post: 01-28-2005, 10:42 AM
  4. redirecting stdout to a socket
    By Kinasz in forum Linux Programming
    Replies: 2
    Last Post: 03-25-2004, 08:01 AM
  5. redirecting stdout
    By Draco in forum C Programming
    Replies: 13
    Last Post: 10-11-2003, 12:56 AM