Library function header file

Library Functions

Library functions are a way to put functions into a library for others to use. The method is to put some commonly used functions into a file for different people to call. When calling, add the file name it is in to #include" to add it. Usually put in the lib file.

head File

In C language family programs, header files are heavily used. In general, each C++/C program usually consists of a header file and a definition file. The header file is used as a carrier file containing function functions and data interface declarations. It is mainly used to save the declaration of the program, and the definition file is used to save the implementation of the program. .c is the program file you wrote.

Library function header file

Library function header file

C/C++ header file list

C, traditional C++

#include "assert.h" //Set the insertion point

#include "ctype.h" //Character Processing

#include "errno.h" //Define the error code

#include "float.h" //Floating point processing

#include "fstream.h" / / file input / output

#include "iomanip.h" //Parameterized input/output

#include "iostream.h" //Data stream input/output

#include "limits.h" / / define the most value constants of various data types

#include "locale.h" / / Define localization function

#include "math.h" //Define the math function

#include "stdio.h" //Define the input/output function

#include "stdlib.h" / / Define miscellaneous functions and memory allocation functions

#include "string.h" / / string processing

#include "strstrea.h" //Array-based input/output

#include 《time.h》 //Define the function about time

#include "wchar.h" //wide character processing and input/output

#include "wctype.h" //wide character classification

//////////////////////////////////////////////////////////// //////////////////////////

Standard C++ (not the same as above)

#include "algorithm" //STL general algorithm

#include "bitset" //STL bit set container

#include 《cctype》

#include "cerrno"

#include 《clocale》

#include 《cmath》

#include "complex" // plural classes

#include 《cstdio》

#include 《cstdlib》

#include 《cstring》

#include 《ctime》

#include "deque" //STL double-ended queue container

#include "Exception" //Exception handling class

#include 《fstream》

#include "functional" //STL defines the operation function (instead of the operator)

#include 《limits》

#include "list" //STL linear list container

#include "map" //STL mapping container

#include 《iomanip》

#include "ios" //Basic input/output support

#include "iosfwd" //predeclaration used by the input/output system

#include 《iostream》

#include "istream" //Basic input stream

#include "ostream" / / basic output stream

#include "queue" //STL queue container

#include "set" //STL collection container

#include "sstream" //string-based stream

#include "stack" //STL stack container

#include "stdexcept" //standard exception class

#include "streambuf" / / underlying input / output support

#include "string" //string class

#include "utility" //STL generic template class

#include "vector" //STL dynamic array container

#include 《cwchar》

#include 《cwctype》

Using namespace std;

//////////////////////////////////////////////////////////// //////////////////////////

C99 increase

#include "complex.h" //Multiple processing

#include "fenv.h" //Floating point environment

#include "inttypes.h" // integer format conversion

#include "stdbool.h" //Boolean environment

#include "stdint.h" //Integer environment

#include "tgmath.h" //General Type Mathematical Macro

C header file Daquan

-------------------------------------------------- -------------------------------------------------- ----------------------------------------

Classification function, the function library is ctype.h

Int isalpha(int ch) If ch is a letter ('A'-'Z', 'a'-'z') returns a non-zero value, otherwise returns 0

Int isalnum(int ch) If ch is a letter ('A'-'Z', 'a'-'z') or a number ('0'-'9') returns a non-zero value, otherwise returns 0

Int isascii(int ch) Returns a non-zero value if ch is a character (0-127 in ASCII), otherwise returns 0

Int iscntrl(int ch) Returns a non-zero value if ch is a void character (0x7F) or a normal control character (0x00-0x1F), otherwise returns 0

Int isdigit(int ch) Returns a non-zero value if ch is a number ('0'-'9'), otherwise returns 0

Int isgraph(int ch) Returns a non-zero value if ch is a printable character (without spaces) (0x21-0x7E), otherwise returns 0

Int islower(int ch) Returns a non-zero value if ch is a lowercase letter ('a'-'z'), otherwise returns 0

Int isprint(int ch) Returns a non-zero value if ch is a printable character (with spaces) (0x20-0x7E), otherwise returns 0

Int ispunct(int ch) Returns a non-zero value if ch is a punctuation character (0x00-0x1F), otherwise returns 0

Int isspace(int ch) If ch is a space (' '), horizontal tab (''), carriage return (''), paper feed ('\f'), vertical tab ('\v '), line feed ('') returns a non-zero value, otherwise returns 0

Int isupper(int ch) Returns a non-zero value if ch is an uppercase letter ('A'-'Z'), otherwise returns 0

Int isxdigit(int ch) If ch is a hexadecimal number ('0'-'9', 'A'-'F', 'a'-'f') returns a non-zero value, otherwise returns 0

Int tolower(int ch) If ch is an uppercase letter ('A'-'Z'), return the corresponding lowercase letter ('a'-'z')

Int toupper(int ch) If ch is a lowercase letter ('a'-'z'), return the corresponding uppercase letter ('A'-'Z')

-------------------------------------------------- -------------------------------------------------- ----------------------------------------

Math function, the function library is math.h, stdlib.h, string.h, float.h

Int abs(int i) returns the absolute value of the integer parameter i

Double cabs(struct complex znum) returns the absolute value of the complex znum

Double fabs(double x) returns the absolute value of the double precision parameter x

Long labs(long n) returns the absolute value of the long integer parameter n

Double exp(double x) returns the value of the exponential function ex

Double frexp(double value, int *eptr) returns the value of x in value=x*2n, where n is stored in eptr

Double ldexp(double value,int exp); returns the value of value*2exp

Double log(double x) returns the value of logex

Double log10(double x) returns the value of log10x

Double pow(double x,double y) returns the value of xy

Double pow10(int p) returns a value of 10p

Double sqrt(double x) returns the value of +√x

Double acos(double x) returns the inverse cosine cos-1(x) value of x, where x is radians

Double asin(double x) returns the inverse sine sin-1(x) value of x, where x is radians

Double atan(double x) returns the arc tangent tan-1(x) value of x, where x is radians

Double atan2(double y,double x) returns the tangent tan-1(x) value of y/x, where x is radians

Double cos(double x) returns the cosine cos(x) value of x, where x is radians

Double sin(double x) returns the sine sin(x) value of x, where x is radians

Double tan(double x) returns the tangent tan(x) value of x, where x is radians

Double cosh(double x) returns the hyperbolic cosine cosh(x) value of x, where x is radians

Double sinh(double x) returns the hyperbolic sine sinh(x) value of x, where x is radians

Double tanh(double x) returns the hyperbolic tangent tanh(x) value of x, where x is radians

Double hypot(double x,double y) returns the length (z) of the hypotenuse of the right triangle, x and y are the length of the right angle, z2=x2+y2

Double ceil(double x) returns the smallest integer not less than x

Double floor(double x) returns the largest integer not greater than x

Void srand(unsigned seed) Initialize random number generator

Int rand() produces a random number and returns this number

Double poly(double x, int n, double c[]) produces a polynomial from the argument

Double modf(double value,double *iptr) Decomposes the double value into a mantissa and a step

Double fmod(double x,double y) returns the remainder of x/y

Double frexp(double value, int *eptr) divides the double precision value into a mantissa and a step

Double atof(char *nptr) converts the string nptr to a floating point number and returns this floating point number

Double atoi(char *nptr) converts the string nptr to an integer and returns this integer

Double atol(char *nptr) converts the string nptr to an integer and returns this integer

Char *ecvt(double value, int ndigit, int *decpt, int *sign) Converts the float value to a string and returns the string

Char *fcvt(double value, int digitin, int *decpt, int *sign) converts the float value to a string and returns the string

Char *gcvt(double value, int ndigit, char *buf) converts the value of a value into a string and stores it in buf, and returns a pointer to buf

Char *ultoa(unsigned long value, char *string, int radix) Converts the unsigned integer value to a string and returns the string, radix is ​​the base used for the conversion

Char *ltoa(long value,char *string, int radix) Converts the long integer value to a string and returns the string, radix is ​​the base used for the conversion

Char *itoa(int value,char *string, int radix) Converts the integer value into a string and stores it in string. radix is ​​the base used in the conversion.

Double atof(char *nptr) converts the string nptr to a double, and returns this number, the error returns 0

Int atoi(char *nptr) converts the string nptr into an integer and returns this number. The error returns 0.

Long atol(char *nptr) converts the string nptr to an integer and returns this number. The error returns 0.

Double strtod(char *str,char **endptr) converts the string str to a double and returns this number.

Long strtol(char *str,char **endptr,int base) converts the string str to an integer and returns this number.

Int matherr(struct exception *e) User modify math error return information function (not necessary)

Double _matherr(_mexcep why,char *fun,double *arg1p, double *arg2p,double retval) User modify math error return information function (not necessary)

Unsigned int _clear87() clears the floating-point status word and returns to the original floating-point state

Void _fpreset() reinitialize floating point math package

Unsigned int _status87() returns the floating point status word

-------------------------------------------------- -------------------------------------------------- ----------------------------------------

Directory function, the function library is dir.h, dos.h

Int chdir(char *path) Makes the specified directory path (such as "C:\\WPS") into the current working directory and returns 0 successfully.

Int findfirst(char *pathname,struct ffblk *ffblk,int attrib) finds the specified file and returns 0 successfully.

Pathname is the specified directory name and file name, such as "C:\\WPS\\TXT"

Ffblk is a structure for specifying file information to be saved, as defined below:

┏━━━━━━━━━━━━━━━━━━┓

┃struct ffblk ┃

┃{ ┃

┃ char ff_reserved[21]; ┃

┃ char ff_attrib; ┃

┃ int ff_ftime; ┃

┃ int ff_fdate; ┃

┃ long ff_fsize; ┃

┃ char ff_name[13]; ┃

┃} ┃

┗━━━━━━━━━━━━━━━━━━┛

Attrib is a file attribute represented by the following characters

┏━━━━━━━━━┳━━━━━━━━┓

┃FA_RDONLY read-only file ┃FA_LABEL volume label ┃

┃FA_HIDDEN hidden file ┃FA_DIREC directory┃

┃FA_SYSTEM system file ┃FA_ARCH file┃

┗━━━━━━━━━┻━━━━━━━━┛

example:

Struct ffblk ff;

Findfirst("*.wps",&ff,FA_RDONLY);

Int findnext(struct ffblk *ffblk) takes the file matching finddirst and returns 0 successfully.

Void fumerge(char *path,char *drive,char *dir,char *name,char *ext)

This function passes the drive letter (C:, A:, etc.), the path dir (\TC, \BC\LIB, etc.).

File name name (TC, WPS, etc.), extension ext (.EXE, .COM, etc.) to form a file name

Save with path.

Int fnsplit(char *path,char *drive,char *dir,char *name,char *ext)

This function breaks the file name path into the drive letter (C:, A:, etc.), the path dir (\TC, \BC\LIB, etc.).

The file name is name (TC, WPS, etc.), and the extension ext (.EXE, .COM, etc.) is stored in the corresponding variable.

Int getcurdir(int drive,char *direc) This function returns the current working directory name of the specified drive

Drive specified drive (0=current, 1=A, 2=B, 3=C, etc.)

Direc saves the variable of the current working path of the specified drive successfully returns 0

Char *getcwd(char *buf,iint n) This function takes the current working directory and stores it in buf until n words

The section is long. Error returns NULL

Int getdisk() takes the currently used drive and returns an integer (0=A, 1=B, 2=C, etc.)

Int setdisk(int drive) Set the drive drive to be used (0=A, 1=B, 2=C, etc.)

Returns the total number of drives available

Int mkdir(char *pathname) Create a new directory pathname and return 0 successfully.

Int rmdir(char *pathname) deletes a directory pathname and returns 0 successfully.

Char *mktemp(char *template) Constructs a file name that is not in the current directory and stores it in the template

Char *searchpath(char *pathname) Use MSDOS to find the path to the file filename.

, this function uses the DOS PATH variable, the file not found returns NULL

-------------------------------------------------- -------------------------------------------------- ----------------------------------------

Process function, the function library is stdlib.h, process.h

Void abort() This function writes a termination message to stderr by calling _exit with exit code 3.

And abnormally terminate the program. No return value

Int exec...Load and run other programs

Int execl( char *pathname,char *arg0,char *arg1,...,char *argn,NULL)

Int execle( char *pathname,char *arg0,char *arg1,...,char *argn,NULL,char *envp[])

Int execlp( char *pathname, char *arg0, char *arg1,...,NULL)

Int execlpe(char *pathname,char *arg0,char *arg1,...,NULL,char *envp[])

Int execv( char *pathname, char *argv[])

Int execve( char *pathname,char *argv[],char *envp[])

Int execvp( char *pathname,char *argv[])

Int execvpe(char *pathname,char *argv[],char *envp[])

The exec function family loads and runs the program pathname and sets the parameters

Arg0(arg1, arg2, argv[], envp[]) is passed to the subroutine, error returns -1

In the exec function family, the suffixes l, v, p, and e are added to exec.

The specified function will have some operational capability

With the suffix p, the function can use the DOS PATH variable to find the subroutine file.

l, the number of parameters passed in the function is fixed.

v, the number of parameters passed in the function is not fixed.

When e, the function passes the specified parameter envp, allowing the environment of the child process to be changed.

When there is no suffix e, the child process uses the environment of the current program.

Void _exit(int status) terminates the current program but does not clean up the scene

Void exit(int status) Terminates the current program, closes all files, writes the output of the buffer (waits for output),

And call the "export function" of any register, no return value

Int spawn...run subroutine

Int spawnl( int mode,char *pathname,char *arg0,char *arg1,...,char *argn,NULL)

Int spawnle( int mode,char *pathname,char *arg0,char *arg1,..., char *argn,NULL,char *envp[])

Int spawnlp( int mode,char *pathname,char *arg0,char *arg1,..., char *argn,NULL)

Int spawnlpe(int mode,char *pathname,char *arg0,char *arg1,..., char *argn,NULL,char *envp[])

Int spawnv( int mode,char *pathname,char *argv[])

Int spawnve( int mode,char *pathname,char *argv[],char *envp[])

Int spawnvp( int mode,char *pathname,char *argv[])

Int spawnvpe(int mode,char *pathname,char *argv[],char *envp[])

The spawn function family runs the subroutine pathname in mode mode and sets the parameters

Arg0(arg1, arg2, argv[], envp[]) is passed to the subroutine. Error return -1

Mode is the operating mode

Mode is P_WAIT to return to the program after the subroutine is finished running.

P_NOWAIT means that the program is run at the same time when the subroutine is running (not available)

P_OVERLAY indicates that the subroutine is run after the program exits.

In the spawn function family, after the suffixes l, v, p, and e are added to the spawn,

The specified function will have some operational capability

When there is a suffix p, the function uses the DOS PATH to find the subroutine file.

l, the number of parameters passed by the function is fixed.

When v, the number of parameters passed by the function is not fixed.

When e, the specified parameter envp can be passed to the subroutine, allowing the subroutine runtime to be changed.

When there is no suffix e, the subroutine uses the environment of the program.

Int system(char *command) Pass the MSDOS command command to DOS to execute

-------------------------------------------------- -------------------------------------------------- ----------------------------------------

Conversion subroutine, the function library is math.h, stdlib.h, ctype.h, float.h

Char *ecvt(double value, int digit, int *decpt, int *sign)

Convert the float value to a string and return the string

Char *fcvt(double value, int digitin, int *decpt, int *sign)

Convert the float value to a string and return the string

Char *gcvt(double value, int ndigit, char *buf)

Convert the value to a string and store it in buf and return the pointer to buf

Char *ultoa(unsigned long value, char *string, int radix)

Converts the unsigned integer value to a string and returns the string, radix is ​​the base used for the conversion

Char *ltoa(long value,char *string,int radix)

Convert the long integer value to a string and return the string, radix is ​​the base used for the conversion

Char *itoa(int value,char *string,int radix)

Convert the integer value to a string and store it in string. radix is ​​the base used in the conversion.

Double atof(char *nptr) converts the string nptr to a double, and returns this number, the error returns 0

Int atoi(char *nptr) converts the string nptr into an integer and returns this number. The error returns 0.

Long atol(char *nptr) converts the string nptr to an integer and returns this number. The error returns 0.

Double strtod(char *str,char **endptr) converts the string str to a double and returns this number.

Long strtol(char *str,char **endptr,int base) converts the string str into an integer,

And return this number,

Int toascii(int c) returns the corresponding ASCII of c

Int tolower(int ch) If ch is an uppercase letter ('A'-'Z'), return the corresponding lowercase letter ('a'-'z')

Int _tolower(int ch) returns the corresponding lowercase letter of ch ('a'-'z')

Int toupper(int ch) If ch is a lowercase letter ('a'-'z'), return the corresponding uppercase letter ('A'-'Z')

Int _toupper(int ch) returns the corresponding uppercase letter of ch ('A'-'Z')

-------------------------------------------------- -------------------------------------------------- ----------------------------------------

Diagnostic function, the function library is assert.h, math.h

Void assert(int test) A macro that expands into an if statement. If the test fails,

Display a message and terminate the program abnormally, no return value

Void perror(char *string) This function will display the most recent error message in the following format:

String string: error message

Char *strerror(char *str) This function returns the most recent error message in the following format:

String str: error message

Int matherr(struct exception *e)

User modify math error return information function (not necessary)

Double _matherr(_mexcep why,char *fun,double *arg1p,

Double *arg2p, double retval)

User modify math error return information function (not necessary)

Input and output subroutine, the function library is io.h, conio.h, stat.h, dos.h, stdio.h, signal.h

Int kbhit() This function returns the most recently pressed button

Int fgetchar() reads a character from the console (keyboard) and displays it on the screen

Int getch() Reads a character from the console (keyboard), not displayed on the screen

Int putch() writes a character to the console (keyboard)

Int getchar() Read a character from the console (keyboard) and display it on the screen

Int putchar() writes a character to the console (keyboard)

Int getche() Read a character from the console (keyboard) and display it on the screen

Int ungetch(int c) Returns the character c back to the console (keyboard)

Char *cgets(char *string) read the string from the console (keyboard) and store it in string

Int scanf(char *format[,argument...]) reads a string from the console and performs each parameter separately.

Assignment, use BIOS to output

Int vscanf(char *format,Valist param) reads a string from the console and performs each parameter separately.

Assignment, use BIOS to output, parameters obtained from Valist param

Int cscanf(char *format[,argument...]) reads a string from the console and performs each parameter separately.

Assignment, directly to the console operation, such as the display when the display character is the direct write frequency display

Int sscanf (char *string, char *format[,argument,...]) through the string string, respectively

Parameter assignment

Int vsscanf (char *string, char *format, Vlist param) through the string string, respectively

Parameter assignment, parameters obtained from Vlist param

Int puts(char *string) sends a string string to the console (monitor),

Output using the BIOS

Void cputs(char *string) sends a string string to the console (monitor),

Directly operate the console, such as the display is directly write frequency display

Int printf(char *format[,argument,...]) Send formatted string output to console (monitor)

Output using the BIOS

Int vprintf(char *format,Valist param) Send formatted string output to console (monitor)

Use the BIOS for output, parameters obtained from Valist param

Int cprintf(char *format[,argument,...]) sends a formatted string output to the console (display),

Directly operate the console, such as the display is directly write frequency display

Int vcprintf(char *format,Valist param) sends a formatted string output to the console (display),

Directly operate the console, such as the display is a direct write frequency display,

Parameters obtained from Valist param

Int sprintf(char *string,char *format[,argument,...])

Rewrite the contents of the string string to the formatted string

Int vsprintf(char *string,char *format,Valist param)

Rewrite the contents of the string string as a formatted string, the parameters are taken from the Valist param

Int rename(char *oldname, char *newname) changes the name of the file oldname to newname

Int ioctl(int handle, int cmd[, int *argdx, int argcx])

This function is used to control the input / output device, please see the following table:

┌───┬────────────────────────────┐

│cmd value│function│

├───┼────────────────────────────┤

│ 0 │Remove device information│

│ 1 │Set device information│

│ 2 │Read argcx bytes into the address pointed to by argdx│

│ 3 │ write argcx byte at the address pointed to by argdx │

│ 4 │ except for the handle as the device number (0=current, 1=A, etc.), the same as cmd=2

│ 5 │ except for the handle as the device number (0=current, 1=A, etc.), the same as cmd=3

│ 6 │ take input status │

│ 7 │ take the output status │

│ 8 │ test interchangeability; only for DOS 3.x │

│ 11 │ Set the recalculation count of the sharing conflict; only for DOS 3.x │

└───┴────────────────────────────┘

Int (*ssignal(int sig, int(*action)())() executes software signals (not necessary)

Int gsignal(int sig) Execute software signal (not necessary)

Int _open(char *pathname, int access) opens a file for reading or writing.

Press and press access to determine whether to read or write the file. The access value is shown in the table below.

┌──────┬────────────────────┐

│access value│meaning│

├──────┼────────────────────┤

│O_RDONLY │Read File│

│O_WRONLY │Write a file│

│O_RDWR │ Read and write │

│O_NOINHERIT │ If the file is not passed to the subroutine, it is included │

│O_DENYALL │ only allows the current processing of files that must be accessed │

│O_DENYWRITE │ only allows reading from any other open file │

│O_DENYREAD │ only allows writing from any other open file │

│O_DENYNONE │Allow other shared open files│

└──────┴────────────────────┘

Int open(char *pathname, int access[, int permiss]) opens a file for reading or writing.

Press and press access to determine whether to read or write the file. The access value is shown in the table below.

┌────┬────────────────────┐

│access value│meaning│

├────┼────────────────────┤

│O_RDONLY│Read file│

│O_WRONLY│Write a file│

│O_RDWR │ Read and write │

│O_NDELAY│ is not used; compatible with UNIX systems│

│O_APPEND│ is read and written, but every write is always added at the end of the file │

│O_CREAT │ If the file exists, this flag is useless; if it does not exist, create a new file │

│O_TRUNC │ If the file exists, the length is truncated to 0, the attribute is unchanged │

│O_EXCL │Not used; compatible with UNIX systems│

│O_BINARY│This flag can be displayed to open the file in binary mode.

│O_TEXT │This flag can be used to display the text in a textual manner.

└────┴────────────────────┘

Permiss is a file attribute and can be the following values:

S_IWRITE allows writing S_IREAD to allow reading S_IREAD|S_IWRITE to allow reading and writing

Int creat(char *filename, int permiss) Create a new file filename and set it

Read and write. Permiss is file readable and can be the following value

S_IWRITE allows writing S_IREAD to allow reading S_IREAD|S_IWRITE to allow reading and writing

Int _creat(char *filename,int attrib) Create a new file filename and set the file

Attributes. Attrib is a file attribute and can be the following value

FA_RDONLY read-only FA_HIDDEN hides the FA_SYSTEM system

Int creatnew(char *filenamt,int attrib) Create a new file filename and set the file

Attributes. Attrib is a file attribute and can be the following value

FA_RDONLY read-only FA_HIDDEN hides the FA_SYSTEM system

Int creattemp(char *filenamt,int attrib) Create a new file filename and set the file

Attributes. Attrib is a file attribute and can be the following value

FA_RDONLY read-only FA_HIDDEN hides the FA_SYSTEM system

Int read(int handle,void *buf,int nbyte) reads nbyte characters from the file with the file number handle

Deposited in buf

Int _read(int handle,void *buf,int nbyte) reads nbyte characters from the file with the file number handle

Save it in buf and call MSDOS directly.

Int write(int handle, void *buf, int nbyte) writes nbyte characters in buf to file number

In the file for the handle

Int _write(int handle, void *buf, int nbyte) writes nbyte characters in buf to file number

In the file for the handle

Int dup(int handle) Copy a file handle pointer, return this pointer

Int dup2(int handle, int newhandle) Copy a file processing pointer handle to newhandle

Int eof(int *handle) checks if the file ends, returns 1 at the end, otherwise returns 0

Long filelength(int handle) Returns the file length, handle is the file number

Int setmode(int handle,unsigned mode) This function is used to set the file with the file number as handle.

Opening mode

Int getftime(int handle,struct ftime *ftime) The time to read the file with the file number handle.

The file time is stored in the ftime structure, and 0 is successfully returned. The ftime structure is as follows:

┌──────────────────┐

│struct ftime │

│{ │

│ unsigned ft_tsec:5; │

│ unsigned ft_min:6; │

│ unsigned ft_hour:5; │

│ unsigned ft_day:5; │

│ unsigned ft_month:4; │

│ unsigned ft_year:1; │

│} │

└──────────────────┘

Int setftime(int handle,struct ftime *ftime) Rewrites the file time with the file number as handle.

The new time is in the structure ftime. Successfully returns 0. The structure ftime is as follows:

┌──────────────────┐

│struct ftime │

│{ │

│ unsigned ft_tsec:5; │

│ unsigned ft_min:6; │

│ unsigned ft_hour:5; │

│ unsigned ft_day:5; │

│ unsigned ft_month:4; │

│ unsigned ft_year:1; │

│} │

└──────────────────┘

Long lseek(int handle, long offset, int fromwhere) This function will use the file with the file number as handle.

The pointer is moved to the offset bytes after fromwhere.

SEEK_SET file switch SEEK_CUR current position SEEK_END file end

Long tell(int handle) This function returns the file pointer with the file number handle, expressed in bytes.

Int isatty(int handle) This function is used to get the type of device handle

Int lock(int handle, long offset, long length) Block file sharing

Int unlock(int handle, long offset, long length) Turns on blocking of file sharing

Int close(int handle) Closes the file processing represented by the handle. The handle is from _creat, creat,

File processing obtained by calling one of creatnew, creattemp, dup, dup2, _open, open

Successfully returns 0 or returns -1, available for UNIX systems

Int _close(int handle) Closes the file processing represented by the handle. The handle is from _creat, creat,

File processing obtained by calling one of creatnew, creattemp, dup, dup2, _open, open

Successfully returns 0 or returns -1, only for MSDOS system

FILE *fopen(char *filename,char *type) Open a file filename, open as type,

And return this file pointer, type can be suffixed with the following string

┌──┬────┬───────┬────────┐

│type│Reading and writing │Text/2-ary file│Build new/Open old file│

├──┼────┼───────┼────────┤

│r │Read│Text│Open old file│

│w │Write│Text│Build New File│

│a │Add│Text│Yes, open, no, new, new │

│r+ │Read/Write│Do not limit│Open│

│w+ │Read/Write│No Limit │New File│

│a+ │Read/Add │No Limit │If you open, Nothing will be built │

└──┴────┴───────┴────────┘

The suffixes that can be added are t and b. Add b to indicate that the file is operated in binary form, t is not necessary to use

Example: ┌──────────────────┐

│#include“stdio.h” │

│main() │

│{ │

│ FILE *fp; │

│ fp=fopen(“C:\\WPS\\WPS.EXE”, “r+b”);│

└──────────────────┘

FILE *fdopen(int ahndle, char *type)

FILE *freopen(char *filename,char *type,FILE *stream)

Int getc(FILE *stream) Reads a character from the stream stream and returns this character

Int putc(int ch,FILE *stream) writes a character ch to the stream stream

Int getw(FILE *stream) Reads an integer from the stream stream and returns EOF error

Int putw(int w,FILE *stream) writes an integer to the stream stream

Int ungetc(char c,FILE *stream) returns the character c back to the stream stream, the next read character will be c

Int fgetc(FILE *stream) Reads a character from the stream stream and returns this character

Int fputc(int ch,FILE *stream) Writes the character ch to the stream stream

Char *fgets(char *string, int n, FILE *stream) Read n characters from the stream stream and store them in string

Int fputs(char *string,FILE *stream) Write string string to stream stream

Int fread(void *ptr, int size, int nitems, FILE *stream) Read nitems from stream stream

A string of length size is stored in ptr

Int fwrite(void *ptr, int size, int nitems, FILE *stream) Write nitems to the stream stream

a string of length size, the string is in ptr

Int fscanf(FILE *stream,char *format[,argument,...]) in formatted form from stream stream

Read in a string

Int vfscanf(FILE *stream,char *format,Valist param) in formatted form from stream stream

Read in a string, the parameters are taken from Valist param

Int fprintf(FILE *stream,char *format[,argument,...]) takes a character in formatted form

String write to the specified stream stream

Int vfprintf(FILE *stream,char *format,Valist param) takes a character in formatted form

Write to the specified stream stream, the parameters are obtained from Valist param

Int fseek(FILE *stream, long offset, int fromwhere) function moves the file pointer to fromwhere

From the backward offset bytes of the pointed position, fromwhere can be the following values:

SEEK_SET file switch SEEK_CUR current position SEEK_END file end

Long ftell(FILE *stream) function returns the current file pointer position positioned in the stream, expressed in bytes

Int rewind(FILE *stream) Moves the current file pointer stream to the beginning of the file

int feof(FILE *stream) 检测流stream上的文件指针是否在结束位置

int fileno(FILE *stream) 取流stream上的文件处理,并返回文件处理

int ferror(FILE *stream) 检测流stream上是否有读写错误,如有错误就返回1

void clearerr(FILE *stream) 清除流stream上的读写错误

void setbuf(FILE *stream,char *buf) 给流stream指定一个缓冲区buf

void setvbuf(FILE *stream,char *buf,int type,unsigned size)

给流stream指定一个缓冲区buf,大小为size,类型为type,type的值见下表

┌───┬───────────────────────────────┐

│type值│意义│

├───┼───────────────────────────────┤

│_IOFBF│文件是完全缓冲区,当缓冲区是空时,下一个输入操作将企图填满整个缓│

│ │冲区。在输出时,在把任何数据写到文件之前,将完全填充缓冲区。 │

│_IOLBF│文件是行缓冲区。当缓冲区为空时,下一个输入操作将仍然企图填整个缓│

│ │冲区。然而在输出时,每当新行符写到文件,缓冲区就被清洗掉。 │

│_IONBF│文件是无缓冲的.buf和size参数是被忽略的。每个输入操作将直接从文│

│ │件读,每个输出操作将立即把数据写到文件中。 │

└───┴───────────────────────────────┘

int fclose(FILE *stream) 关闭一个流,可以是文件或设备(例如LPT1)

int fcloseall() 关闭所有除stdin或stdout外的流

int fflush(FILE *stream) 关闭一个流,并对缓冲区作处理

处理即对读的流,将流内内容读入缓冲区;

对写的流,将缓冲区内内容写入流。成功返回0

int fflushall() 关闭所有流,并对流各自的缓冲区作处理

处理即对读的流,将流内内容读入缓冲区;

对写的流,将缓冲区内内容写入流。成功返回0

int access(char *filename,int amode) 本函数检查文件filename并返回文件的属性,

函数将属性存于amode中,amode由以下位的组合构成

06可以读、写04可以读02可以写01执行(忽略的) 00文件存在

如果filename是一个目录,函数将只确定目录是否存在

函数执行成功返回0,否则返回-1

int chmod(char *filename,int permiss) 本函数用于设定文件filename的属性

permiss可以为以下值

S_IWRITE允许写S_IREAD允许读S_IREAD|S_IWRITE允许读、写

int _chmod(char *filename,int func[,int attrib]);

本函数用于读取或设定文件filename的属性,

当func=0时,函数返回文件的属性;当func=1时,函数设定文件的属性

若为设定文件属性,attrib可以为下列常数之一

FA_RDONLY只读FA_HIDDEN隐藏FA_SYSTEM系统

接口子程序,所在函数库为:dos.h、bios.h

unsigned sleep(unsigned seconds)暂停seconds微秒(百分之一秒)

int unlink(char *filename)删除文件filename

unsigned FP_OFF(void far *farptr)本函数用来取远指针farptr的偏移量

unsigned FP_SEG(void far *farptr)本函数用来没置远指针farptr的段值

void far *MK_FP(unsigned seg,unsigned off)根据段seg和偏移量off构造一个far指针

unsigned getpsp()取程序段前缀的段地址,并返回这个地址

char *parsfnm(char *cmdline,struct fcb *fcbptr,int option)

函数分析一个字符串,通常,对一个文件名来说,是由cmdline所指的一个命令行。

文件名是放入一个FCB中作为一个驱动器,文件名和扩展名.FCB是由fcbptr所指

定的.option参数是DOS分析系统调用时,AL文本的值。

int absread(int drive,int nsects,int sectno,void *buffer)本函数功能为读特定的

磁盘扇区,drive为驱动器号(0=A,1=B等),nsects为要读的扇区数,sectno为开始的逻

辑扇区号,buffer为保存所读数据的保存空间

int abswrite(int drive,int nsects,int sectno,void *buffer)本函数功能为写特定的

磁盘扇区,drive为驱动器号(0=A,1=B等),nsects为要写的扇区数,sectno为开始的逻

辑扇区号,buffer为保存所写数据的所在空间

void getdfree(int drive,struct dfree *dfreep)本函数用来取磁盘的自由空间,

drive为磁盘号(0=当前,1=A等)。函数将磁盘特性的由dfreep指向的dfree结构中。

dfree结构如下:

┌───────────────────┐

│struct dfree │

│{ │

│ unsigned df_avail; │

│ unsigned df_total; │

│ unsigned df_bsec; │

│ unsigned df_sclus; │

│} │

└───────────────────┘

char far *getdta() 取磁盘转换地址DTA

void setdta(char far *dta)设置磁盘转换地址DTA

void getfat(int drive,fatinfo *fatblkp)

本函数返回指定驱动器drive(0=当前,1=A,2=B等)的文件分配表信息

并存入结构fatblkp中,结构如下:

┌──────────────────┐

│struct fatinfo │

│{ │

│ char fi_sclus; │

│ char fi_fatid; │

│ int fi_nclus; │

│ int fi_bysec; │

│} │

└──────────────────┘

void getfatd(struct fatinfo *fatblkp) 本函数返回当前驱动器的文件分配表信息,

并存入结构fatblkp中,结构如下:

┌──────────────────┐

│struct fatinfo │

│{ │

│ char fi_sclus; │

│ char fi_fatid; │

│ int fi_nclus; │

│ int fi_bysec; │

│} │

└──────────────────┘

int bdos(int dosfun,unsigned dosdx,unsigned dosal)本函数对MSDOS系统进行调用,

dosdx为寄存器dx的值,dosal为寄存器al的值,dosfun为功能号

int bdosptr(int dosfun,void *argument,unsiigned dosal)本函数对MSDOS系统进行调用,

argument为寄存器dx的值,dosal为寄存器al的值,dosfun为功能号

int int86(int intr_num,union REGS *inregs,union REGS *outregs)

执行intr_num号中断,用户定义的寄存器值存于结构inregs中,

执行完后将返回的寄存器值存于结构outregs中。

int int86x(int intr_num,union REGS *inregs,union REGS *outregs,

struct SREGS *segregs)执行intr_num号中断,用户定义的寄存器值存于

结构inregs中和结构segregs中,执行完后将返回的寄存器值存于结构outregs中。

int intdos(union REGS *inregs,union REGS *outregs)

本函数执行DOS中断0x21来调用一个指定的DOS函数,用户定义的寄存器值

存于结构inregs中,执行完后函数将返回的寄存器值存于结构outregs中

int intdosx(union REGS *inregs,union REGS *outregs,struct SREGS *segregs)

本函数执行DOS中断0x21来调用一个指定的DOS函数,用户定义的寄存器值

存于结构inregs和segregs中,执行完后函数将返回的寄存器值存于结构outregs中

void intr(int intr_num,struct REGPACK *preg)本函数中一个备用的8086软件中断接口

它能产生一个由参数intr_num指定的8086软件中断。函数在执行软件中断前,

从结构preg复制用户定义的各寄存器值到各个寄存器。软件中断完成后,

函数将当前各个寄存器的值复制到结构preg中。参数如下:

intr_num 被执行的中断号

preg为保存用户定义的寄存器值的结构,结构如下

┌──────────────────────┐

│struct REGPACK │

│{ │

│ unsigned r_ax,r_bx,r_cx,r_dx; │

│ unsigned r_bp,r_si,r_di,r_ds,r_es,r_flags; │

│} │

└──────────────────────┘

函数执行完后,将新的寄存器值存于结构preg中

void keep(int status,int size)以status状态返回MSDOS,但程序仍保留于内存中,所占

用空间由size决定。

void ctrlbrk(int (*fptr)()) 设置中断后的对中断的处理程序。

void disable() 禁止发生中断

void enable() 允许发生中断

void geninterrupt(int intr_num)执行由intr_num所指定的软件中断

void interrupt(* getvect(int intr_num))() 返回中断号为intr_num的中断处理程序,

例如: old_int_10h=getvect(0x10);

void setvect(int intr_num,void interrupt(* isr)()) 设置中断号为intr_num的中

断处理程序为isr,例如: setvect(0x10,new_int_10h);

void harderr(int (*fptr)()) 定义一个硬件错误处理程序,

每当出现错误时就调用fptr所指的程序

void hardresume(int rescode)硬件错误处理函数

void hardretn(int errcode) 硬件错误处理函数

int inport(int prot) 从指定的输入端口读入一个字,并返回这个字

int inportb(int port)从指定的输入端口读入一个字节,并返回这个字节

void outport(int port,int word) 将字word写入指定的输出端口port

void outportb(int port,char byte)将字节byte写入指定的输出端口port

int peek(int segment,unsigned offset) 函数返回segment:offset处的一个字

char peekb(int segment,unsigned offset)函数返回segment:offset处的一个字节

void poke(int segment,int offset,char value) 将字value写到segment:offset处

void pokeb(int segment,int offset,int value) 将字节value写到segment:offset处

int randbrd(struct fcb *fcbptr,int reccnt)

函数利用打开fcbptr所指的FCB读reccnt个记录。

int randbwr(struct fcb *fcbptr,int reccnt)

函数将fcbptr所指的FCB中的reccnt个记录写到磁盘上

void segread(struct SREGS *segtbl)函数把段寄存器的当前值放进结构segtbl中

64V Battery pack

64V Battery Pack ,Lithium Battery Box,Lithium Power Pack,Jackery Battery Pack

Zhejiang Casnovo Materials Co., Ltd. , https://www.casnovonewenergy.com