C + + functions commonly used

Source: Internet
Author: User
Tags character classes cos file handling sin square root stdin terminates uppercase letter

Isalnum determines whether a character is a number or letter of a character class
Isalpha determine if a character is a letter
Isblank determines whether a character is a white space character (space, Horizontal tab, TAB)
Iscntrl judge a control (character between ASCII 0-31)
IsDigit determines whether a character is a number of character classes
Isgraph determines whether a character is a printable character (a character between ASCII 33-126)
Islower to determine if a character is a lowercase letter
Isprint determines whether a character is a printable character (a character between ASCII 33-126) that contains a space
ISPUNCT determines whether a character is a punctuation mark other than a space, letter, or number.
Isspace determines that a character is a white space character (space, line break, paper break, carriage return, vertical tab, Horizontal tab).
Isupper determines whether a character is an uppercase letter
Isxdigit determines whether a character is a hexadecimal number
ToLower to convert uppercase characters to lowercase
ToUpper convert lowercase characters to uppercase

size_t sizeof
NULL Empty pointer
Types of file files
The position of the pointer in the fpos_t file
EOF File End <0
Filename_max file name maximum value >0
Fopen_max the maximum number of simultaneous open files >8
Seek_set file Header
Seek_cur File Current Location
Seek_end file End
File *fopen (const char *filename,const char * mode);
File *freopen (const char *filename,const char* mode,file *stream) changes the current stream-related files
int fclose (file *stream) close files
void Clearerr (file *stream) clears the error flag in the stream or the end of file flag
The end of file flag on the test stream of the int feof (file *stream)
Error flags on the int ferror (FILE *stream) test flow
int ungetc (int c,file *stream) descriptors a word back into the stream
int fgetc (FILE *stream) reads a character from the stream
int getc (FILE *stream) reads a character from the stream
int FPUTC (int c, FILE *stream) writes a character to a stream
int PUTC (int c, FILE *stream) writes a character to a stream
Char *fgets (char *s, int n, FILE *stream) gets a string from the stream
int fputs (const char *s, FILE *stream) writes a string to a stream
int fprintf (FILE *stream,const char *format, ...) Print a stream of formatted data to a
int vfprintf (FILE *stream,const char *format, va_list AP) uses a parameter list pointer to format data to the stream
int fscanf (FILE *stream, const char *format, ...) Reading formatted data from a stream
size_t fread (char *buffer,size_t size,size_t count,file *stream) reads data from a stream
int fwrite (const char *buffer,size_t size,size_t count,file *stream) writes data to a stream
int Fgetpos (file *stream, fpos_t *pos) Gets the location indicator of the stream
int Fsetpos (FILE *stream, const fpos_t *pos) Sets the flow position indicator
int fseek (file *stream, long offset, int origin) moves the file pointer to a specified position
Long Ftell (file *stream) Gets the offset of the document pointer relative to the file header
void Rewind (file *steam) repositions a file pointer to the beginning of the file
int remove (const char *path) Deletes a file
int rename (const char *oldname, const char *newname) changes a file or directory
_IOFBF Full buffer: reads the data from the stream when the buffer is empty. or write data to the stream when the buffer is full
_IOLBF row buffering: Each time a row of data is read from the stream or a row of data is written to the stream
_IONBF unbuffered: Reads data directly from the stream or writes data directly to the stream without a buffer
BufSize Buffer size >=256
int fflush (FILE *stream) refreshes a stream and empties the contents of the stream-related buffer
void Setbuf (FILE *stream, char *buffer) control flow buffer, has been replaced by setvbuf
int setvbuf (FILE *stream, char *buffer, int mode, size_t size) control the buffer type and buffer size of the stream
int sprintf (char *buffer, const char *format, ...) Writes a formatted data to a string
int sscanf (const char *buffer, const char *format, ...) To read formatted data from a string
int vsprintf (char *buffer, const char *format, va_list AP) is formatted from the parameter list pointer to a string
L_tmpnam temporary file name length >0
Tmp_max the maximum number of unique file names generated >=25
File *tmpfile (void) creates a temporary file in binary read-write mode
Char *tmpname (char *string) creates a temporary file name
stdin standard input stream
STDOUT standard output stream
STDERR standard Error Output stream
int GetChar (void) obtains one character from stdin
int Putchar (int c) writes the character stdout
Char *gets (char *buffer) gets a row from stdin
int puts (const char *string) writes a string to stdout
void perror (const char *error) prints an error message to STDERR
int printf (const char *format, ...) Print formatted data to stdout
int scanf (const char *format, ...) Read formatted data from stdin
int vprintf (const char *format, va_list AP) is formatted from the parameter list pointer to stdout

int abs (int i) returns the absolute value of the integral type 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 exponent function ex
Double Frexp (double value,int *eptr) returns the value of x in VALUE=X*2N, 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 X's Y-square
Double pow10 (int p) Returns the value of the P-square of 10
Double sqrt (double x) returns the square root of X
Double ACOs (double x) returns the inverse cosine cos-1 (x) value of x, X is radians
Double asin (double x) returns the inverse sine sin-1 (x) value of x, X is radians
Double Atan (double x) returns the arc tangent tan-1 (x) value of x, X is radians
Double atan2 (double y,double x) returns the inverse tangent tan-1 (x) value of y/x, and X for Y is radians
Double cos (double x) returns the cosine cos (x) value of x, X is radians
Double sin (double x) returns the sine sin (x) value of x, X is radians
Double tan (double x) returns the tangent tan (x) value of x, X is radians
Double cosh (double x) returns the hyperbolic cosine cosh (x) value of x, in radians
Double Sinh (double x) returns the hyperbolic sine sinh (x) value of x, in radians
Double Tanh (double x) returns the hyperbolic tangent tanh (x) value of x, in radians
Double Hypot (double x,double y) returns the length of the right triangle hypotenuse (z)
Double ceil (double x) returns the smallest integer not less than X
Double floor (double x) returns the largest integer less than x
void Srand (unsigned seed) initializes the random number generator
int rand () produces a random number and returns the number
Double poly (double x,int n,double c[]) produces a polynomial from a parameter
Double modf (doubles value,double *iptr) breaks the value of doubles into mantissa and order
Double Fmod (double x,double y) returns the remainder of X/y
Double Frexp (double value,int *eptr) divides the value of doubles into mantissa and order
Double atof (char *nptr) converts the string nptr to a floating-point number and returns the floating-point number
Double atoi (char *nptr) converts the string nptr to an integer and returns the integer
Double Atol (char *nptr) converts the string nptr to grow an integer and returns the integer
Char *ecvt (double value,int ndigit,int *decpt,int *sign) Converts the floating-point value to a string and returns the string
Char *fcvt (double value,int ndigit,int *decpt,int *sign) Converts the floating-point value to a string and returns the string
Char *gcvt (double value,int Ndigit,char *buf) Converts the number of value to a string coexisting 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 an integer value into a string to be stored in String,radix as the base used for the conversion
Double atof (char *nptr) converts the string nptr to a double-precision number and returns this number, with the error returning 0
int atoi (char *nptr) converts the string nptr to an integer number, returns the number, and returns the error 0
Long Atol (char *nptr) converts the string nptr to the number of growth integers and returns this number, with the error returning 0
Double strtod (char *str,char **endptr) converts the string str to a double-precision number and returns the number
Long Strtol (char *str,char **endptr,int Base) converts the string str to the growth integer and returns the number
int Matherr (struct exception *e) user modifies mathematical error return information function (no need to use)
unsigned int _clear87 () clears the floating-point status Word and returns the original floating-point state
void _fpreset () re-initialize the floating-point math package
unsigned int _status87 () returns the floating-point status word

int chdir (char *path) makes the specified directory path (e.g. "C:\\wps") into the current working directory, and succeeds returns 0
int FindFirst (char *pathname,struct ffblk *ffblk,int attrib) finds the specified file and returns 0 successfully
int FindNext (struct ffblk *ffblk) takes a matching Finddirst file 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.), path dir (\TC, \bc\lib, etc.), filename name ( TC, WPS, etc.), extension ext (. EXE,. COM, etc.) to form a file name in the path
int Fnsplit (char *path,char *drive,char *dir,char *name,char *ext) This function decomposes the file name path into drive (C:, A: etc.), path dir (\TC, \bc\lib, etc.) FileName name (TC, WPS, etc.), extension ext (. EXE,. COM, etc.), and separately into the corresponding variable
int getcurdir (int drive,char *direc) This function returns the current working directory name of the specified drive, drives specified drive (0= current, 1=a,2=b,3=c, etc.) Direc Save the specified drive the current working path of the variable returned successfully 0
Char *getcwd (char *buf,iint N) This function takes the current working directory and stores it in buf until the N bytes are long. Error returned NULL
int Getdisk () takes the drive that is currently in use, returns an integer (0=a,1=b,2=c, etc.)
int setdisk (int drive) sets the drives to be used (0=a,1=b,2=c, etc.), returning the total number of drives that can be used
int mkdir (char *pathname) establishes a new directory pathname, which successfully returns 0
int rmdir (char *pathname) deleted a directory pathname, successfully returned 0
Char *mktemp (char *template) constructs a file name that does not exist on the current directory in the template
Char *searchpath (char *pathname) uses MSDOS to find the path to the file filename, which uses a DOS path variable, and the file is not found to return NULL

void abort () This function writes a terminating message to stderr by calling _exit with exit code 3, and terminates the program abnormally. No return value
int exec ... Loading and running other programs exec function family
void _exit (int status) terminates the current program, but does not clean the scene
void exit (int status) terminates the current program, closes all files, writes the output of the buffer (waits for output), and calls the "Exit function" of any register, no return value
int spawn ... Run subroutine spawn function family
The int system (char *command) passes MSDOS command commands to DOS execution

int _open (char *pathname,int access) to open a file for read or write, press access to determine whether to read a file or to write a file, Access value check table
int open (char *pathname,int access[,int Permiss]) Open a file for read or write, press access to determine whether to read the file or to write the file, access values look up the table. Permiss is a file attribute,
int creat (char *filename,int Permiss) creates a new file filename and sets the read-write nature.
int _creat (char *filename,int attrib) establishes a new file filename and sets the file properties. Attrib is a file attribute,
int creatnew (char *filenamt,int attrib) establishes a new file filename and sets the file properties. attrib for file attributes
int creattemp (char *filenamt,int attrib) establishes a new file filename and sets the file properties. Attrib is a file attribute,
int read (int handle,void *buf,int nbyte) reads Nbyte characters from a file with a file number of handle in BUF
NT _read (int handle,void *buf,int nbyte) reads handle characters from a file with file number Nbyte and calls BUF directly for operation
int write (int handle,void *buf,int nbyte) writes Nbyte characters from BUF to a file with file number handle
int _write (int handle,void *buf,int nbyte) writes BUF characters from Nbyte to a file with file number handle
int dup (int handle) copies a file processing pointer handle, returns this pointer
int dup2 (int handle,int newhandle) copies a file processing pointer handle to Newhandle
int eof (int *handle) checks whether the file ends, returns 1, or 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 how files with file number handle are opened
int getftime (int handle,struct ftime *ftime) reads the time of a file with file number handle and saves the file time in the Ftime structure, successfully returning 0
int setftime (int handle,struct ftime *ftime) overrides file number handle file time, new time in structure Ftime. Successful return 0.
Long Lseek (int handle,long offset,int fromwhere) This function moves the pointer of a file with the file number handle to the first offset byte after Fromwhere
Long tell (int handle) This function returns a file pointer with a file number of handle, in bytes
int isatty (int handle) This function is used to take the type of device handle
int lock (int handle,long offset,long length) to block file sharing
int unlock (int handle,long offset,long length) to open a block on file sharing
int close (int handle) Close the file handling represented by handle
int _close (int handle) Closes the file handling represented by handle

Mem... Operation storage Array, mem ... All members of the series manipulate the storage array. In all of these functions, the array is n bytes long. memcpy copies an n-byte block from source to Destin. If the source and target blocks overlap, select the copy direction, in example, to copy the overwritten bytes correctly.
void *memccpy (void *destin,void *source,unsigned char ch,unsigned N)
void *memchr (void *s,char ch,unsigned N) copies bytes from source to Destin. One of the following occurs when the copy is complete: (1) the character Ch preferred copy to Destin. (2) n bytes copied to Destin
void *memcmp (void *s1,void *s2,unsigned N) compares exactly two strings with a length of n bytes S1 and S2.
int memicmp (void *s1,void *s2,unsigned N) compares the first n bytes of S1 and S2, regardless of the uppercase or lowercase characters of a character
void *memmove (void *destin,void *source,unsigned N) memmove same as memcpy
void *memcpy (void *destin,void *source,unsigned N)
void *memset (void *s,char ch,unsigned N) places all bytes of s into byte ch. The length of the s array is given by n
void Movedata (int segsrc,int offsrc,int segdest,int offdest,unsigned numbytes) The SEGSRC:OFFSRC at the source address (numbytes) Bytes copied to the destination address (segdest:offdest)
void Movemem (void *source,void *destin,unsigned len) copies a long Len byte of data from source to Destin. If the source and destination address strings overlap, select the copy direction to copy the data correctly
void Setmem (void *addr,int Len,char value) places the first byte of the block referred to by addr in byte value.

Str... String manipulation functions
Char stpcpy (char *dest,const char *src) copies the string src to the Dest
Char strcat (char *dest,const char *src) adds the string src to the end of the Dest
Char strchr (const char *s,int c) Retrieves and returns the position of the first occurrence of the character C in the string s
the int strcmp (const char *s1,const char *s2) compares the size of the string S1 with the S2 and returns the S1-S2
Char strcpy (char *dest,const char *src) copies the string src to the Dest
size_t strcspn (const char *s1,const char *s2) scans S1, returns the number of characters in S1 that are also in S2
Char strdup (const char *s) copies the string s to the most recently created cell
int stricmp (const char *s1,const char *s2) compares strings S1 and S2, and returns S1-S2
size_t strlen (const char *s) Returns the length of the string s
Char strlwr (char *s) converts all uppercase letters in the string s to lowercase letters and returns the converted string
Char strncat (char *dest,const char *src,size_t maxlen) copies up to maxlen characters in string src to string dest
int strncmp (const char *s1,const char *s2,size_t maxlen) compares the string S1 with the first S2 characters in MaxLen
Char strncpy (char *dest,const char *src,size_t maxlen) copies the first maxlen characters in SRC to dest
int strnicmp (const char *s1,const char *s2,size_t maxlen) compares the string S1 with the first S2 characters in MaxLen
Char Strnset (char *s,int ch,size_t N) places the first n characters of a string s in Ch
Char strpbrk (const char *s1,const char *s2) scans the string S1 and returns the number of characters in both S1 and S2
Char strrchr (const char *s,int c) scans the last occurrence of a given character C for a string s
Char Strrev (char *s) rearranges the characters in the string s in reverse order and returns the arranged string
Char strset (char *s,int ch) places all the characters in a string s in a given character ch
size_t strspn (const char *s1,const char *s2) scans the string S1 and returns the number of characters in both S1 and S2
Char strstr (const char *s1,const char *s2) scans the string S2 and returns the location of the first occurrence of S1
Char strtok (char *s1,const char *s2) retrieves the string S1, which is delimited by the delimiter defined in the string s1
Char Strupr (char *s) converts all lowercase letters in the string s to uppercase letters and returns the converted string

Storage Allocation sub-program, where the library is Dos.h, alloc.h, malloc.h, Stdlib.h, process.h
int AllocMem (unsigned size,unsigned *seg) allocates free memory using DOS, size is allocated memory, SEG is allocated memory pointer
int Freemem (unsigned seg) frees previously allocated memory by ALLOCMEM, SEG is the specified memory pointer
int setblock (int seg,int newsize) modifies the allocated memory length, the SEG is the memory pointer of the allocated memory, newsize for the new length
int brk (void *endds) This function is used to change the amount of space allocated to the calling program's data segment, and the new Space end address is Endds
char *sbrk (int incr) This function is used to increase the amount of space allocated to the calling program's data segment, increasing the space of incr bytes
unsigned long coreleft () This function returns the length of the unused store, in bytes
void *calloc (unsigned nelem,unsigned elsize) allocates a pointer to Nelem memory space and returns the allocated memory
void *malloc (unsigned size) allocates a size byte of memory space and returns a pointer to the allocated memory
void free (void *ptr) frees previously allocated memory, and the pointer to the memory to be freed is PTR
void *realloc (void *ptr,unsigned newsize) alters the size of allocated memory, PTR is a pointer to a memory area that has been allocated, newsize for the new length, and returns the allocated memory pointer.
Long Farcoreleft () returns the length of unused storage in the far heap, in bytes
void far *farcalloc (unsigned long units,unsigned long Unitsz) allocates units memory space from the remote heap and returns a pointer to the allocated memory
void *farmalloc (unsigned long size) allocates a size byte of memory space and returns the allocated memory pointer
void Farfree (void far *block) frees previously allocated memory space from the far heap, and the pointer to the remote heap of memory to be freed is block
void Far *farrealloc (*block,unsigned long newsize) changes the size of the allocated remote heap memory, the block is a pointer to the memory area allocated, Newzie for the new length, returns the allocated memory pointer

Time-date functions, function libraries for time.h, dos.h
Char *ctime (long *clock) converts the time that the clock refers to, such as the time returned by the function, to a string in the following format: Mon-Nov-11:31:54 1983\n\0
Char *asctime (struct TM *tm) converts the time of the specified TM structure class into a string in the following format: Mon-Nov-11:31:54 1983\n\0
Double Difftime (time_t time2,time_t time1) calculates the time gap (in seconds) between the structure Time2 and time1
The struct TM *gmtime (long *clock) converts the time at which the clock is referred to, such as the time returned by the function, to GMT and returns in the form of a TM structure.
struct TM *localtime (long *clock) This function converts the time at which a clock is referred to (such as the time the function is returned) to local standard time and returns as a TM structure
void Tzset () This function provides compatibility with UNIX operating systems
Long Dostounix (struct date *dateptr,struct time *timeptr) converts the date indicated by dateptr to the UNIX format, and returns from GMT January 1970 1 The number of seconds from dawn to now
void Unixtodos (long utime,struct date *dateptr,struct time *timeptr) The number of seconds since the beginning of the morning of January 1, 1970 GMT Utime converted to DOS format and saved in the user The structure of the dateptr and the Timeptr
void getdate (struct date *dateblk) writes the date within the computer to the structure dateblk for use by the user
void setdate (struct date *dateblk) This function changes the date in the computer to the date specified by the structure dateblk
void gettime (struct time *TIMEP) writes the Times within the computer to the structure TIMEP for use by the user
void SetTime (struct time *timep) changes the times in the computer to the time referred to by the structure TIMEP
Long *tloc gives the number of seconds elapsed from the wee hours of the morning of January 1, 1970 of Greenwich Mean Time, and saves the value in the cell referred to by tloc
int stime (long *tp) This function writes the time that the TP refers to (for example, the time it returns) to the computer.

C + + functions commonly used

Related Article

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.