466
|
1 <chapter>
|
|
2 <title>C Standard Library</title>
|
|
3 <para>
|
|
4 The Standard Library contains functions which fall into two
|
|
5 classes: high-level I/O and convenience.
|
|
6 </para>
|
468
|
7 <para>
|
|
8 The high-level I/O functions provide facilities that are
|
|
9 normally considered part of the definition of other languages; for
|
|
10 example, the FORMAT "statement" of Fortran. In addition, automatic
|
|
11 buffering of I/O channels improves the speed of file access because
|
|
12 fewer system calls are necessary.
|
|
13 </para>
|
610
|
14 <para>
|
|
15 The high-level I/O functions should not be confused with the
|
|
16 low-level system calls with similar names. Nor shoul "file
|
|
17 pointers" be confused with "path numbers". The standard library
|
|
18 functions maintain a structure for each file open that holds status
|
|
19 information and a pointer into the files buffer, A user program
|
|
20 uses a pointer to this structure as the "identity" of the file
|
|
21 (which is provided by "fopen()"), and passes it to the various
|
|
22 I/O functions. The I/O functions will make the low-level system
|
|
23 calls when necessary.
|
|
24 </para>
|
|
25 <para>
|
|
26 <emphasis>Using a file pointer in a systen call, or a path number in a
|
|
27 Standard Library call</emphasis>, is a common mistake among beginners to C and,
|
|
28 if made, will be sure to <emphasis>crash your program.</emphasis>
|
|
29 </para>
|
|
30 <para>
|
|
31 The convenience functions include facilities for copying,
|
|
32 comparing, and concatening strings, converting numbers to strings,
|
|
33 and doing the extra work in accessing systen information such as the
|
|
34 time.
|
|
35 </para>
|
|
36 <para>
|
|
37 In the page which follow, the functions available are
|
|
38 described in terms of what they do and the parameters they expect.
|
|
39 The "USAGE" section shows the name of the function and the type
|
|
40 returned (if not int). The declaration of arguments are shown as
|
|
41 they would be written in the function definition to indicate the
|
|
42 types expected by the function. If it is necesary to include a
|
|
43 file before the function can be used, it is shown in the "USAGE"
|
|
44 section by "#include <filename>".
|
|
45 </para>
|
|
46 <para>
|
|
47 Most of the header files that are required to be included, must
|
|
48 reside in the "DEFS" directory on the default system drive. If the
|
|
49 file is included in the source program using angle bracket
|
|
50 delimiters instead of the usual double quotes, the compiler will
|
|
51 append this path name to the file name. For example, "#include <stdio.h>"
|
|
52 is equivalent to "#include </d0/defs/stdio.h>", if "/d0" is
|
|
53 the path name of the default system drive.
|
|
54 </para>
|
|
55 <para>
|
|
56 <emphasis>Please note</emphasis> that if the type of the valye returned by a
|
|
57 function is not INT, you should make a pre-declaration in your
|
|
58 program before calling it. For example, if you wish to use
|
|
59 "atof()", you should pre-declare by having "double atof();"
|
|
60 somewhere in your program before a call to it. Some functions
|
|
61 which have associated header files in the DEFS directory that
|
|
62 should be included, will be pre-declared for you in the header. An
|
|
63 example of this is "ftell()" which is pre-declared in "stdio.h". If
|
|
64 you are in any doubt, read the header file.
|
|
65 </para>
|
466
|
66
|
|
67 &atofref;
|
570
|
68 &fcloseref;
|
466
|
69 &feofref;
|
|
70 &findstrref;
|
|
71 &fopenref;
|
|
72 &freadref;
|
|
73 &fseekref;
|
|
74 &getcref;
|
|
75 &getsref;
|
|
76 &isalpharef;
|
|
77 &l3tolref;
|
|
78 &longjmpref;
|
|
79 &mallocref;
|
|
80 &mktempref;
|
472
|
81 &printfref;
|
466
|
82 &putcref;
|
|
83 &putsref;
|
|
84 &qsortref;
|
|
85 &scanfref;
|
|
86 &setbufref;
|
|
87 &sleepref;
|
|
88 &strcatref;
|
|
89 &systemref;
|
|
90 &toupperref;
|
|
91 &ungetcref;
|
|
92 </chapter>
|