Thread: fprintf stdin

  1. #1
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326

    fprintf stdin

    Why is it when I use fprintf(stdin, "%d", 20);

    I can't just use scanf and retrieve that value? I am just trying to figure out how writing to different streams works.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    fprintf() writes to an output stream.

    stdin is an input stream.

    Therefore your code has a conflict.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I can't just use scanf and retrieve that value?
    It doesn't work that way. For now just think of fprintf as writing to the screen (which can't be read from) and scanf as reading from the keyboard (which can't be written to). So using that model, you can't write to the screen with fprintf and then read what you just wrote because the screen isnt an input stream.

    -Prelude
    My best code is written with the delete key.

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, 01:01 AM
  2. help with basic program
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 02-01-2006, 04:19 PM
  3. program not working...please look at this
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 01-30-2006, 10:33 PM
  4. fprintf to stderr crash programs
    By jlai in forum Windows Programming
    Replies: 2
    Last Post: 04-12-2005, 08:51 AM
  5. Multithreading problem
    By Bacardi34 in forum C Programming
    Replies: 5
    Last Post: 09-02-2004, 02:26 PM