Thread: what's the type of stdin?

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229

    what's the type of stdin?

    I am trying to make a rw version of popen (by returning a pair of pipes), but I am having trouble dup2'ing stdin to an end of a pipe.

    Code:
    dup2(wpipe[0], stdin);
    Gives
    Code:
    test.c:18: warning: passing argument 2 of ‘dup2’ makes integer from pointer without a cast
    How do I turn it into a file descriptor then? and what exactly is it?

    [edit]
    and
    Code:
    dup2(wpipe[0], *stdin);
    gives
    test.c:18: error: incompatible type for argument 2 of ‘dup2’
    Last edited by cyberfish; 04-23-2009 at 08:56 PM.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    fileno(stdin)

    EDIT: But stdin is file descriptor 0, by definition.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    I see. Thanks.

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by cyberfish View Post
    I see. Thanks.
    As far as what type stdin is, it's equivalent to a FILE *.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 01:03 AM
  3. typename madness
    By zxcv in forum C++ Programming
    Replies: 4
    Last Post: 05-13-2006, 10:35 PM
  4. Changing an objects Type
    By ventolin in forum C++ Programming
    Replies: 2
    Last Post: 06-29-2004, 07:18 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM