Commands to stdin

This is a discussion on Commands to stdin within the C Programming forums, part of the General Programming Boards category; Hi, is it possible to direct an output to the stdin stream? What command would do this if you can ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    137

    Commands to stdin

    Hi, is it possible to direct an output to the stdin stream? What command would do this if you can do it? Short post I know but it doesn't take much explaining.
    Cheers
    http://uk.geocities.com/ca_chorltonkids

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    stdin is for input, stdout and stderr are for output. Use them in the same manner you would any other file stream. Does that help?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    137
    So something like putc could do it?
    putc ( whatever,stdin )
    if I pass the character x to putc for example and direct it to stdin would the computer read it in the same way as me pressing x on the keyboard?
    http://uk.geocities.com/ca_chorltonkids

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    No, you can't write to an input stream... the best you might be able to do is unget 1 character. But why do this with stdin?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    137
    I wasn't asking for any program in particular, it was just a thought that came to me. It would be more useful if it was the stdin of another program though.
    http://uk.geocities.com/ca_chorltonkids

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You can do it in Windows in various ways (WriteConsoleInput, WriteFile on open standard console handles).......

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    137
    Thanks a lot
    http://uk.geocities.com/ca_chorltonkids

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  2. Replies: 2
    Last Post: 07-12-2008, 01:00 PM
  3. Replies: 2
    Last Post: 07-27-2007, 01:48 PM
  4. Question About Reading Lines from stdin
    By Zildjian in forum C Programming
    Replies: 7
    Last Post: 11-12-2003, 05:45 AM
  5. stdin question
    By oomen3 in forum C Programming
    Replies: 6
    Last Post: 02-19-2003, 02:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21