comparison docs/ccguide/getc.refentry @ 597:2e76fecc5ca0

All refentries finished.
author roug
date Fri, 15 Nov 2002 21:49:51 +0000
parents 253b6096ee01
children 94ff9d15614f
comparison
equal deleted inserted replaced
596:fe8e46eca1ed 597:2e76fecc5ca0
28 28
29 </refsynopsisdiv> 29 </refsynopsisdiv>
30 30
31 <refsect1><title>Description</title> 31 <refsect1><title>Description</title>
32 <para> 32 <para>
33 Placeholder 33 Getc returns the next character from the file pointed to by
34 "fp".
35 </para>
36 <para>
37 Getchar is equivalent to "getc(stdin)".
38 </para>
39 <para>
40 Getw returns the next two bytes from the file as an integer.
41 </para>
42 <para>
43 Under OS-9 there is a choice of service requests to use when
44 reading from a file. "Read()" will get characters up to a
45 specified number in "raw" mode i.e. no editing will take
46 place on the input stream and the characters will appear to the
47 program exactly as in the file. "Readln()", on the other
48 hand, will honor the various mappings of characters
49 associated with a Serial Character device such as a terminal
50 and in any case will return to the caller as soon as a carriage
51 return is seen on the input.
52 </para>
53 <para>
54 In the vast majority of cases, it is preferable to use
55 "readln()" for accessing Serial Character devices and "read()"
56 for any other file input. "Getc()" uses this strategy and, as
57 all file input using the Standard Library functions is routed
58 through "getc()", so do all the other input functions. The
59 choice is made when the first call to "getc()" is made after
60 the file has been opened. The system is consulted for the
61 status of the file and a flag bit is set in the file structure
62 accordingly. The choice may be forced by the programmer by
63 setting the relevant bit before a call to "getc()". The flag
64 bits are defined in "&lt;stdio.h&gt;" and "_SCF" and "_RBF" and the
65 method is as follows: assuming that the file pointer for the
66 file, as returned by "fopen()" is f,
67 <programlisting>
68 f->_flag |= _SCF;
69 </programlisting>
70 will force the use of "readln()" on input and
71 <programlisting>
72 f->_flag |= _RBF;
73 </programlisting>
74 will force the use of "read()". This trick may be played on
75 the standard streams "stdin", "stdout" and "stderr" without the
76 need for calling "fopen()" but before any input is requested
77 from the stream.
34 </para> 78 </para>
35 </refsect1> 79 </refsect1>
36 80
37 <refsect1><title>Diagnostics</title> 81 <refsect1><title>Diagnostics</title>
38 <para> 82 <para>