9.12. Character I/OA number of functions provide for character oriented I/O. Their declarations are: #include <stdio.h> /* character input */ int fgetc(FILE *stream); int getc(FILE *stream); int getchar(void); int ungetc(int c, FILE *stream); /* character output */ int fputc(int c, FILE *stream); int putc(int c, FILE *stream); int putchar(int c); /* string input */ char *fgets(char *s, int n, FILE *stream); char *gets(char *s); /* string output */ int fputs(const char *s, FILE *stream); int puts(const char *s); Their descriptions are as follows. 9.12.1. Character inputThese read an There is also the supporting 9.12.2. Character outputThese are identical in description to the input functions already
described, except performing output. They return the character written, or
9.12.3. String outputThese write strings to the output file; 9.12.4. String input
Gets works similarly for the stream stdin, but discards the newline! Both return s if successful, or a null pointer otherwise. In each case, if EOF is encountered before any characters have been read, the array is unchanged and a null pointer is returned. A read error in the middle of a string leaves the array contents undefined and a null pointer is returned. |
The C BookThis book is published as a matter of historical interest. Please read the copyright and disclaimer information. GBdirect Ltd provides up-to-date training and consultancy in C, Embedded C, C++ and a wide range of other subjects based on open standards if you happen to be interested. |
|
West Yorkshire Office
GBdirect Ltd
Training: 0800 651 0338 Please call between 0900 and 1700 (UK time) on Monday to Friday South East Regional Office
GBdirect Ltd
Training: 0800 651 0338 Please call between 0900 and 1700 (UK time) on Monday to Friday Please note: |