C Language Learning Tutorials Tenth-documents (8)

Source: Internet
Author: User
Tags assert constant constant definition error code function prototype range time limit

File detection function

C language commonly used in the file detection function has the following several.
First, the end of the file detection function feof function call format: feof (file pointer);
Function: To determine whether the file is at the end of the file, such as the end of the file, the return value is 1, otherwise 0.

Second, read and write file error detection function ferror function call format: ferror (file pointer);
Function: Check the file for errors when reading and writing with various input and output functions. If the Ferror return value of 0 means that there is no error, otherwise there is a fault.

Third, file error mark and file end flag set 0 function clearerr function call format: clearerr (file pointer);
Function: This function clears the error flag and the file end flag so that they are 0 values.

C Library Files

C system provides a wealth of system files, called library files, c library files are divided into two categories, one is the extension of ". h" files, called header files, in the previous include commands we have used many times. The ". h" file contains information such as constant definitions, type definitions, macro definitions, function prototypes, and various compilation selection settings. The other is the function library, which includes the target code for the various functions that the user invokes in the program. Typically, when a library function is called in a program, the ". h" file that contains the function prototype is included before the call.
All library functions are given in the appendix.
ALLOC. H describes memory management functions (allocation, release, etc.).
Assert. H defines an assert debug macro.
Bios. H describes the functions that invoke the IBM-PC ROM bios subroutine.
CONIO. H describes the functions that invoke the DOS console I/O subroutine.
CTYPE. H contains name class information about character classification and conversion (such as Isalpha and Toascii).
DIR. H contains the structure, macro definitions, and functions for directories and paths.
Dos. H defines and describes some of the constants and functions of the MSDOS and 8086 calls.
Erron. H defines the mnemonic for the error code.
Fcntl. H defines the symbolic constants when connecting to an open library subroutine.
FLOAT. H contains some parameters and functions about floating-point operations.
GRAPHICS. H describes the functions of the graphics function, the constant definition of the graphics error code, the various color values of the different drivers, and some special structures used by the function.
Io. H contains the structure and description of low-level I/O subroutines.
LIMIT. H contains information such as environment parameters, compile time limit, number range and so on.
MATH. H describes the mathematical operation function, also set the HUGE VAL macro, explains the Matherr and Matherr subroutine to use the special structure.
Mem. H describes some memory manipulation functions (most of which are also described in STRING.H).
PROCESS. H describes the various functions of process management, spawn ... and exec ... The structure description of the function.
SETJMP. H defines the type of jmp buf the longjmp and setjmp functions use, and describes the two functions.
SHARE. H defines the parameters of a file share function.
SIGNAL. H defines Sig[zz (z] [zz)]ign and Sig[zz (z] [zz)]DFL constants, which describe the RAJSE and signal two functions.
Stdarg. H defines a macro that reads the function parameter table. (such as the Vprintf,vscarf function).
Stddef. H defines some common data types and macros.
STDIO. H defines the types and macros of the standards and extensions defined by Kernighan and Ritchie in Unix System V. Standard I/O predefined streams are also defined: Stdin,stdout and stderr, which describe the I/O Flow subroutine.
Stdlib. H describes some commonly used subroutines: conversion subroutines, search/sorting subroutines, and so on.
STRING. H describes some string operations and memory operation functions.
Sys\stat. H defines some symbolic constants that are used when opening and creating files.
Sys\types. H illustrates the Ftime function and the TIMEB structure.
Sys\time. H defines the type of time Time[zz (Z] [ZZ)]t.
Time. H defines the structure of the time conversion subroutine Asctime, localtime, and gmtime, the types used by CTime, Difftime, Gmtime, localtime, and Stime, and provides prototypes for these functions.
VALUE. H defines some important constants, including those that are dependent on machine hardware and that are described for compatibility with Unix System V, including the range of floating-point and double values.

Summary of this chapter

1. The C system treats the file as a "stream" and is processed by byte.

2. c files are encoded into binary files and ASCII files.

3. C language, the file pointer identifies the file, and when a file is opened, you can get the file pointer.

4. The file must be opened before reading and writing, and must be closed.

5. The file can be opened by read-only, write-only, read-write, append-four operations, and must also specify whether the file type is a binary or a text file.

6. Files can be read and written in bytes, strings, blocks of data, and files can be read and written in the specified format.

7. The position pointer inside the file indicates the current read/write location, and moving the pointer enables random read and write to the file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.