fscanf(stderr,"%d",&i); ?!?!?

Gustaaf-Jan Heinhuis heinhuis at dri.nl
Tue Apr 23 23:57:06 AEST 1991


In article <1991Apr23.075320.9473 at en.ecn.purdue.edu> 
tenka at en.ecn.purdue.edu (Andy Tenka) writes:

>In desperation to get the input from keyboard, I used:
>
>	fscanf(stderr,"%d",&i);
>
>However, the fscanf does not wait for input from keyboard.
>It just reads 0 from stderr before I even type anything.
>I know I did something wrong here.  Could any of you gurus
>point out my mistakes

Ever tried to read from screen??????? 
Since when is stderr linked to a keyboard?????!!!!!!!!

The kernel links stdin to the keyboard (_iob[0]), stdout an stderr to the
screen (_iob[1] and _iob[2] resp.) *****before***** the program starts.
Redirecting results in the kernel linking stdin to the file instead of to
the keyboard.

>and also, could you show me a way to
>write a program that takes input from both redirected stdin
>and keyboard?  Many thanks in advance.

This is elementary (do hope I will not regret this remark, no flames)

You simply open a file for reading ( fopen(filename, "w") ). You have 
three options:
      1): supply filename as an argument to your program.
      2): let the user supply the filename ( scanf("%s", &name) )
      3): you always read from the same file, i.e. filename is a string
	  constant.

Hope this helps, Gustaaf-Jan.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++---===To all virgins, thanks for nothing.===---++++++++++++++
          
   ___              GJ Heinhuis student comp. sc. HIO Enschede (Holland)
  /  _)             Final Project at: DataCount, Wierden, Holland
 |  ____ ___        Mail: heinhuis at dri.nl
  \__/|   |         
      |___|         Everybody is entitled to his own	
  |   |   |         opinion, as long as it's mine!
   \_/    |         Not necessarely DataCount's opinion!!



More information about the Comp.lang.c mailing list