摘要: 1.7 Error FunctionsMany of the functions in the library set status indicators when error or end of file occur. Theseindicators may be set and tested explicitly. In addition, the integer expression errno (declaredin <errno.h>) may contain an error number that gives further information about the 阅读全文
posted @ 2013-03-20 22:57 freewater 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 1.6 File Positioning Functionsint fseek(FILE *stream, long offset, int origin)fseek sets the file position for stream; a subsequent read or write will access databeginning at the new position. For a binary file, the position is set to offset charactersfrom origin, which may be SEEK_SET (beginning), 阅读全文
posted @ 2013-03-20 22:54 freewater 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 1.5 Direct Input and Output Functionssize_t fread(void *ptr, size_t size, size_t nobj, FILE *stream)fread reads from stream into the array ptr at most nobj objects of size size. freadreturns the number of objects read; this may be less than the number requested. feofand ferror must be used to determ 阅读全文
posted @ 2013-03-20 22:50 freewater 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 1.4 Character Input and Output Functionsint fgetc(FILE *stream)fgetc returns the next character of stream as an unsigned char (converted to anint), or EOF if end of file or error occurs.char *fgets(char *s, int n, FILE *stream)fgets reads at most the next n-1 characters into the array s, stopping if 阅读全文
posted @ 2013-03-20 22:49 freewater 阅读(328) 评论(0) 推荐(0) 编辑
摘要: Formatted InputThe scanf function deals with formatted input conversion.int fscanf(FILE *stream, const char *format, ...)fscanf reads from stream under control of format, and assigns converted values throughsubsequent arguments, each of which must be a pointer. It returns when format is exhausted.fs 阅读全文
posted @ 2013-03-20 22:47 freewater 阅读(197) 评论(0) 推荐(0) 编辑
摘要: Formatted OutputThe printf functions provide formatted output conversion.int fprintf(FILE *stream, const char *format, ...)fprintf converts and writes output to stream under the control of format. The return valueis the number of characters written, or negative if an error occurred.int printf(const 阅读全文
posted @ 2013-03-20 22:32 freewater 阅读(199) 评论(0) 推荐(0) 编辑
摘要: File OperationsThe following functions deal with operations on files. The type size_t is the unsigned integraltype produced by the sizeof operator.FILE *fopen(const char *filename, const char *mode)fopen opens the named file, and returns a stream, or NULL if the attempt fails. Legalvalues for mode i 阅读全文
posted @ 2013-03-20 21:49 freewater 阅读(305) 评论(0) 推荐(0) 编辑