Annotation of coherent/a/usr/man/ALL/getc, revision 1.1.1.1

1.1       root        1: 
                      2: 
                      3: getc()                     STDIO Macro                     getc()
                      4: 
                      5: 
                      6: 
                      7: 
                      8: Read character from file stream
                      9: 
                     10: #include <stdio.h>
                     11: iinntt ggeettcc(_f_p) FFIILLEE *_f_p;
                     12: 
                     13: getc is a  macro that reads a character from  the file stream _f_p,
                     14: and returns an int.
                     15: 
                     16: ***** Example *****
                     17: 
                     18: The following  example creates a  simple copy utility.   It opens
                     19: the first file named on  the command line and copies its contents
                     20: into the second file named on the command line.
                     21: 
                     22: 
                     23: #include <stdio.h>
                     24: 
                     25: 
                     26: 
                     27: void fatal(string)
                     28: char *string;
                     29: {
                     30:         printf("%s\n", string);
                     31:         exit (1);
                     32: }
                     33: 
                     34: 
                     35: 
                     36: main(argc, argv)
                     37: int argc; char *argv[];
                     38: {
                     39:         int foo;
                     40:         FILE *source, *dest;
                     41: 
                     42: 
                     43: 
                     44:         if (--argc != 2)
                     45:                 fatal("Usage: copy [source][destination]");
                     46: 
                     47: 
                     48: 
                     49:         if ((source = fopen(argv[1], "r")) == NULL)
                     50:                 fatal("Cannot open source file");
                     51:         if ((dest = fopen(argv[2], "w")) == NULL)
                     52:                 fatal("Cannot open destination file");
                     53: 
                     54: 
                     55: 
                     56:         while ((foo = getc(source)) != EOF)
                     57:                 putc(foo, dest);
                     58: }
                     59: 
                     60: 
                     61: 
                     62: 
                     63: 
                     64: COHERENT Lexicon                                           Page 1
                     65: 
                     66: 
                     67: 
                     68: 
                     69: getc()                     STDIO Macro                     getc()
                     70: 
                     71: 
                     72: 
                     73: ***** See Also *****
                     74: 
                     75: fgetc(), getchar(), putc(), STDIO
                     76: 
                     77: ***** Diagnostics *****
                     78: 
                     79: getc returns EOF at end of file or on read fatal.
                     80: 
                     81: ***** Notes *****
                     82: 
                     83: Because  getc is  a macro, arguments  with side  effects probably
                     84: will  not work  as  expected.  Also,  because getc  is a  complex
                     85: macro, its use in expressions of too great a complexity may cause
                     86: unforeseen  difficulties.  Use  of the  function fgetc  may avoid
                     87: this.
                     88: 
                     89: 
                     90: 
                     91: 
                     92: 
                     93: 
                     94: 
                     95: 
                     96: 
                     97: 
                     98: 
                     99: 
                    100: 
                    101: 
                    102: 
                    103: 
                    104: 
                    105: 
                    106: 
                    107: 
                    108: 
                    109: 
                    110: 
                    111: 
                    112: 
                    113: 
                    114: 
                    115: 
                    116: 
                    117: 
                    118: 
                    119: 
                    120: 
                    121: 
                    122: 
                    123: 
                    124: 
                    125: 
                    126: 
                    127: 
                    128: 
                    129: 
                    130: COHERENT Lexicon                                           Page 2
                    131: 
                    132: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.