File descriptors and streams and copying thereof.

Gjalt de Jong gjalt at euteal
Thu Apr 13 17:26:13 AEST 1989


I found this piece of code in original article:

>	stdin->fd = my_file->fd;
>	if (yyparse()) /* stuff*/ else /* stuff */
>	stdin->fd = 0;	/* presume stdin is/was fd 0 */

I do not hope there are many people out there using this tricky stuff to get
the file descriptor of a stream. Because, not all machines have this file
descriptor field in the file pointer structure!

But there are better ways to get information about streams. You can
use 'fileno', which is defined in <stdio.h>, to get the file descriptor of
a stream. 

--
Gjalt G. de Jong,                 | Phone: +(31)40-473345
Eindhoven University of Technology, Dept. of Electr. Eng.
P.O. Box 513, 5600 MB Eindhoven, The Netherlands
Email: gjalt at euteal       UUCP: {...}!mcvax!hp4nl!euteal!gjalt



More information about the Comp.lang.c mailing list