int spawn…runs a subprogram
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 subprogram pathname in mode mode, and passes the parameters arg0(arg1,arg2,argv,envp) to the subprogram. Returns -1 on error
mode is the run mode:
mode is P_WAIT means return to this program after the subprogram finishes running
P_NOWAIT means run this program at the same time while the subprogram is running (not usable)
P_OVERLAY means run the subprogram after this program exits
In the spawn function family, when the suffixes l、v、p、e are added after spawn, the specified function will have a certain capability
With suffix p, the function uses DOS's PATH to find the subprogram file
l, the number of parameters passed to the function is fixed.
v, the number of parameters passed to the function is not fixed.
e, the specified parameter envp can be passed to the subprogram, allowing the subprogram runtime environment to be changed.
Without suffix e, the subprogram uses this program's environment.
int system(char *command)
passes the MSDOS command command to DOS for execution and conversion subprogram, libraries are math.h、stdlib.h、ctype.h、float.h
char *ecvt(double value,int ndigit,int *decpt,int *sign)
converts floating-point number value to a string and returns that string
char *fcvt(double value,int ndigit,int *decpt,int *sign)
converts floating-point number value to a string and returns that string
char *gcvt(double value,int ndigit,char *buf)
converts number value to a string, stores it in buf, and returns the pointer to buf
char *ultoa(unsigned long value,char *string,int radix)
converts unsigned integer value to a string and returns that string, radix is the base used in conversion
char *ltoa(long value,char *string,int radix)
converts long integer value to a string and returns that string, radix is the base used in conversion
char *itoa(int value,char *string,int radix)
converts integer value to a string and stores it in string, radix is the base used in conversion
double atof(char *nptr) converts string nptr to a double-precision number and returns it, returns 0 on error
int atoi(char *nptr) converts string nptr to an integer and returns it, returns 0 on error
long atol(char *nptr) converts string nptr to a long integer and returns it, returns 0 on error
double strtod(char *str,char **endptr)
converts string str to a double-precision number and returns it,
long strtol(char *str,char **endptr,int base)
converts string str to a long integer and returns it,
int toascii(int c) returns the ASCII corresponding to c
int tolower(int ch) if ch is an uppercase letter ('A'-'Z'

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

for ch
int toupper(int ch) if ch is a lowercase letter ('a'-'z'

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

for ch
Diagnostic functions, in the libraries assert.h、math.h
void assert(int test) a macro expanded like an if statement, if test fails, it displays a message and abnormally terminates the program, no return value
void perror(char *string) this function displays the most recent error message, in the format: string string:error message
char *strerror(char *str) this function returns the most recent error message, in the format: string str:error message
int matherr(struct exception *e)
user function to modify math error return information (not necessary to use)
double _matherr(_mexcep why,char *fun,double *arg1p, double *arg2p,double retval)
user function to modify math error return information (not necessary to use)
Input/output subroutines, libraries are io.h、conio.h、stat.h、dos.h、stdio.h、signal.h
int kbhit() this function returns the most recently pressed key
int fgetchar() reads a character from the console (keyboard) and displays it on the screen
int getch() reads a character from the console (keyboard) without displaying it on the screen
int putch() writes a character to the console (keyboard)
int getchar() reads a character from the console (keyboard) and displays it on the screen
int putchar() writes a character to the console (keyboard)
int getche() reads a character from the console (keyboard) and displays it on the screen
int ungetch(int c) returns character c to the console (keyboard)
char *cgets(char *string) reads a string from the console (keyboard) and stores it in string
int scanf(char *format)
reads a string from the console, assigns values to each parameter respectively, and uses BIOS for output
int vscanf(char *format,Valist param)
reads a string from the console, assigns values to each parameter respectively, and uses BIOS for output, parameters are taken from Valist param
int cscanf(char *format)
reads a string from the console, assigns values to each parameter respectively, and operates directly on the console, for example the display writes characters directly to video memory
int sscanf(char *string,char *format)
assigns values to each parameter respectively through string string
int vsscanf(char *string,char *format,Vlist param)
assigns values to each parameter respectively through string string, parameters are taken from Vlist param
int puts(char *string) sends a string string to the console (display), using BIOS for output
void cputs(char *string) sends a string string to the console (display), operating directly on the console, for example the display uses direct video-memory writing
int printf(char *format)
sends formatted string output to the console (display), using BIOS for output
int vprintf(char *format,Valist param)
sends formatted string output to the console (display), using BIOS for output, parameters are taken from Valist param
int cprintf(char *format)
sends formatted string output to the console (display), operating directly on the console, for example the display uses direct video-memory writing
int vcprintf(char *format,Valist param)
sends formatted string output to the console (display), operating directly on the console, for example the display uses direct video-memory writing, parameters are taken from Valist param
int sprintf(char *string,char *format)
rewrites the contents of string string as a formatted string
int vsprintf(char *string,char *format,Valist param)
rewrites the contents of string string as a formatted string, parameters are taken from Valist param
int rename(char *oldname,char *newname)changes the name of file oldname to newname
int ioctl(int handle,int cmd)
this function is used to control input/output devices, see the table below:
┌───┬────────────────────────────┐
│cmd value │function │
├───┼────────────────────────────┤
│ 0 │get device information │
│ 1 │set device information │
│ 2 │read argcx bytes into the address pointed to by argdx │
│ 3 │write argcx bytes to the address pointed to by argdx │
│ 4 │same as cmd=2 except handle is treated as a device number (0=current,1=A, etc.) │
│ 5 │same as cmd=3 except handle is treated as a device number (0=current,1=A, etc.) │
│ 6 │get input status │
│ 7 │get output status │
│ 8 │test removability; DOS 3.x only │
│ 11 │set share-conflict retry count; DOS 3.x only │
└───┴────────────────────────────┘
int (*ssignal(int sig,int(*action)())() executes a software signal (not necessary to use)
int gsignal(int sig) executes a software signal (not necessary to use)
int _open(char *pathname,int access)opens a file for reading or writing, then determines whether to read or write according to access, see the table below for access values
┌──────┬────────────────────┐
│access value │meaning │
├──────┼────────────────────┤
│O_RDONLY │read file │
│O_WRONLY │write file │
│O_RDWR │both read and write │
│O_NOINHERIT │if the file is not passed to the subprogram, it is included │
│O_DENYALL │only the current process is allowed to access the file │
│O_DENYWRITE │only reading from any other open file is allowed │
│O_DENYREAD │only writing from any other open file is allowed │
│O_DENYNONE │allows other shared opens of the file │
└──────┴────────────────────┘
int open(char *pathname,int access)opens a file for reading or writing, then determines whether to read or write according to access, see the table below for access values
┌────┬────────────────────┐
│access value│meaning │
├────┼────────────────────┤
│O_RDONLY│read file │
│O_WRONLY│write file │
│O_RDWR │both read and write │
│O_NDELAY│unused; for UNIX system compatibility │
│O_APPEND│both read and write, but each write always appends to 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, its length is truncated to 0 and attributes remain unchanged │
│O_EXCL │unused; for UNIX system compatibility │
│O_BINARY│this flag can explicitly specify opening the file in binary mode │
│O_TEXT │this flag can be used to explicitly specify opening the file in text mode│
└────┴────────────────────┘
permiss is the file attribute, it can be the following values:
S_IWRITE allows write S_IREAD allows read S_IREAD|S_IWRITE allows read and write
int creat(char *filename,int permiss) creates a new file filename, and sets its read/write properties.
permiss is the file read/write property, it can be the following values
S_IWRITE allows write S_IREAD allows read S_IREAD|S_IWRITE allows read and write
int _creat(char *filename,int attrib) creates a new file filename, and sets file attributes.
attrib is the file attribute, it can be the following values
FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system
int creatnew(char *filenamt,int attrib) creates a new file filename, and sets file attributes.
attrib is the file attribute, it can be the following values
FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system
int creattemp(char *filenamt,int attrib) creates a new file filename, and sets file attributes.
attrib is the file attribute, it can be the following values
FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system
int read(int handle,void *buf,int nbyte) reads nbyte characters from the file with file number handle into buf
int _read(int handle,void *buf,int nbyte) reads nbyte characters from the file with file number handle into buf, directly calling MSDOS for the operation.
int write(int handle,void *buf,int nbyte) writes nbyte characters from buf to the file with file number handle
int _write(int handle,void *buf,int nbyte) writes nbyte characters from buf to the file with file number handle
int dup(int handle) duplicates a file handle handle and returns this handle
int dup2(int handle,int newhandle) duplicates a file handle handle to newhandle
int eof(int *handle) checks whether the file has ended, returns 1 if ended, otherwise returns 0
long filelength(int handle) returns the file length, handle is the file number