Linux C common functions

Source: Internet
Author: User
Tags set socket square root string format system log time and date

(1) Character test functionIsalnum (test whether the character is an English letter or a number) Isalpha (test character is an English letter) Isascii (test character is ASCII character) Isblank (test character is a space character) Iscntrl ( Test whether the character is an ASCII control character isdigit (test character is an Arabic numeral) isgraph (test character is a printable character) islower (test character is lowercase English letter) isprint (test character is a printable character) Isspace (test if character is a space character) ispunct (test character is a punctuation mark or special symbol) Isupper (test character is uppercase English letter) Isxdigit (test character is a 16 binary number) (2) Data conversion functionAtof (Converts a string to a floating-point number) 1atoi (converts a string to an integer) Atol (converts a string to a growth integer) ECVT (converts a floating-point number to a string, 19 rounding) FCVT (converts a floating-point number to a string, 20 rounding) GCVT ( Converts a floating-point number to a string, 21 rounding) (3) memory configuration functionAlloca (Configuration memory space) BRK (changes the range of data bytes) calloc (configuration memory space) free (frees the previously configured memory) GetPageSize (get memory paging size) malloc (configuration memory space) mmap (establish memory map) Munmap (DE-memory mapped) realloc (change the memory space you have configured) SBRK (increase the data space available to the program) (4) Time functionAsctime (Time and date in string format) clock (takes approximately the time the process consumes the CPU) CTime (the time and date are represented in string format) Difftime (calculate time Gap) Ftime (takes the current time and date) Gettimeofday (Get current time) gmtime (get current time and date) localtime (get local current time and date) Mktime (convert time structure data to elapsed seconds) Settimeofday (set current time) strftime ( Format date and time) time (get current) Tzset (set timezone for time conversion) (5) String processing functionBCMP (compare memory contents) bcopy (copy memory contents) Bzero (to clear a memory content to 0) FFS (finds the first true bit in an integer) index (finds the first occurrence of a string in the specified character) memccpy (copy memory contents) MEMCHR ( Find a specific character in a memory range memcmp (compare memory contents) memcpy (copy memory contents) Memfrob (encode memory area) memmove (copy memory contents) memset (fills a memory space with a value) Rindex ( Finds the last occurrence of a specified character in a string) strcasecmp (ignores case comparison string) strcat (concatenate two strings) STRCHR (finds the first occurrence of a string in the specified character) strcmp (compare String) strcoll ( Compare strings using the current region's character order) strcpy (copy string) strcspn (returns the number of characters in a string that does not contain the specified string content) strdup (copy string) Strfry (character in a randomly reconstituted string) strlen (returns string length) STRNCASECMP (ignores case comparison string) Strncat (concatenate two strings) strncmp (compare String) strncpy (copy string) Strpbrk (finds the first occurrence of a string in the specified character) STRRCHR ( Finds the last occurrence of a specified character in a string strspn (returns the number of characters in a string that are contiguous to the specified string content) Strstr (finds the specified string in a string) strtok (split string) (6) Mathematical calculation functionABS (calculates the absolute value of the integer number) ACOs (take the inverse cosine function values) ASIN (take the sine function value) atan (take the inverse tangent function value) atan2 (get the inverse tangent function value) ceil (take the minimum integer number not less than the parameter) cos (take the cosine function value) cosh ( Take the hyperbolic cosine function value) div (obtains quotient and remainder after dividing two integers) exp (computed exponent) fabs (calculates the absolute value of the floating-point number) frexp (divides the floating-point number into the base and exponent) Hypot (calculates the right triangle hypotenuse length) Labs (calculates the absolute value of the long integer number) Ldexp (Calculates the second-party value of 2) Ldiv (obtains the quotient and remainder of the division of two long integers) log (calculates the pairs of values based on E) log10 (calculates the pairs of values based on 10) modf (decomposition of floating-point numbers into integers and decimals) Pow (calculates the quadratic value) sin (takes the value of the sine function) Sinh (take hyperbolic sine function value) sqrt (calculate square root value) tan (take tangent function value) tanh (take hyperbolic tangent function value) (7) User and group functionsCuserid (get user account name) endgrent (Close Group file) endpwent (close password file) endutent (Close utmp file) fgetgrent (read group format from specified file) fgetpwent ( From the specified file to read the password format) getegid (obtain a valid group identifier) GETEUID (obtain a valid user identification number) Getgid (obtain the Real Group Identification code) getgrent (get the data from the group file file) Getgrgid ( Obtain data from the group file for the specified GID) Getgrnan (Gets the data for the specified group from the group file) getgroups (Gets the group code) GetLogin (Gets the login user account name) GETPW (Gets the password file data for the specified user) Getpwent ( Get the data from the password file) Getpwnam (obtains the data of the specified account from the password file) Getpwuid (obtains the data of the specified UID from the password file) Getuid (obtains the real user identification Code) getutent (obtains the account login data from the Utmp file) Getutid (find a specific record from the Utmp file) Getutline (find a specific record from the Utmp file) initgroups (Initialize group manifest) logwtmp (logs a login data to a wtmp file) Pututline ( Write utmp record to file) Setegid (set valid group identifier) SETEUID (set valid user ID) setfsgid (set the file system's group identification number) Setfsuid (set the file system's user ID) setgid (set the real Group identification code) Setgrent (read group data from the group file from the beginning) setgroups (set Group code) setpwent (read the account data from the password file from the beginning) Setregid (set real and valid group ID) setreuid (set real and valid user identification code) Setuid (set Real user identification number) setutent (read login data from utmp/file from scratch) updwtmp (logs a login data to wtmp file) utmpname (set utmp file path) (8) Data encryption functionCrypt (password or data encoded) Getpass (get a password input) (9) Data structure functionBsearch (two USD Search) hcreate (hash table) hdestory (delete hash table) Hsearch (hash Table Search) Insque (Join an item into the queue) Lfind (linear search) Lsearch (linear search) Qsort ( Arrange arrays with quick sorting rremque (delete an item from the queue) Tdelete (delete data from a two-fork tree) tfind (search binary tree) tsearch (binary tree) Twalk (visit two fork tree) (10) random number functionDrand48 (produces a positive floating-point random number) erand48 (produces a positive floating-point random number) Initstate (establishes a random number state array) jrand48 (produces a long integer number of random numbers) lcong48 (sets the random number seed for 48-bit operations) Lrand48 (produces a positive long integer random number) mrand48 (produces a long integer random number) nrand48 (produces a positive long integer random number) rand (generates random number) random (generates random number) seed48 (sets the random number seed of 48-bit operation) SetState (establish random number state array) Srand (set random number Seed) srand48 (set random number seed for 48-bit operation) Srandom (set random number Seed) (11) Primary I/O functionsClose (Close file) creat (create file) DUP (copy file descriptor) dup2 (copy file descriptor) fcntl (file description word operation) Flock (lock file or unlock) Fsync (write buffer data back to disk) Lseek (move file read and write location) Mkstemp (Create a unique temporary file) open (open file) read (read data from an open file) sync (writes buffer data back to disk) write (writes data to an open file) (12) standard I/O functionsClearerr (clear file stream error flag) fclose (Close file) fdopen (convert file descriptor to file pointer) feof (check that the file stream is read to the end of the file) fflush (update buffer) fgetc (read one character from file) Fgetpos ( Gets the file stream read location) fgets (reads a string from the file) Fileno (returns the file descriptor used by the file stream) fopen (opens the file) FPUTC (writes a specified character to the file stream) Fputs (writes a specified string to the file) fread ( Read data from a file stream) freopen (open file) fseek (move file stream read/write location) fsetpos (move file stream read-write location) Ftell (take file stream reading location) fwrite (write data to file stream) getc (read one character from file) GetChar (read in one character from the standard input device) gets (read in a string from the standard input device) Mktemp (generates a unique temporary file filename) PUTC (writes a specified character to the file) Putchar (writes the specified character to the standard output device) puts ( Writes the specified string to the standard output device) Rewind (resets the file stream's read-write location to the beginning of the file) setbuf (sets the buffer of the file stream) SetBuffer (sets the buffer of the file stream) Setlinebuf (sets the file stream to a linear buffer) setvbuf ( Sets the buffer of the file stream) tmpfile (create temporary file) ungetc (writes a specified character back to the file stream) (13) process and Process ControlAbort (end process abnormally) assert (terminates the process if the condition of the test is not established) atexit (function called before the program ends properly) execl (execute file) execle (execute file) EXECLP (find file from PATH environment variable and execute) EXECV (Execute file) execve (execute file) EXECVP (execute file) exit (normal end process) _exit (end Process Execution) fork (establish a new process) Getpgid (get process group ID) GETPGRP (get process group ID) Getpid (get process ID) getppid (get process identifier of parent process) GetPriority (Get program Process Execution priority) longjmp (jump to original setjmp saved stack environment) Nice (change process precedence) On_exit ( Set function called before normal end of program) Ptrace (process tracking) setjmp (save current stack environment) Setpgid (set process group ID) SETPGRP (set process group identifier) SetPriority (Set Program Process execution priority) SIGLONGJMP (Jump to the previously sigsetjmp saved stack environment) SIGSETJMP (save current stack environment) system (execute shell command) Wait (wait for the child process to break or end) Waitpid (wait for the child process to break or end) (14) Format the output function of the senderfprintf (formatted output data to file) fscanf (formatted string input) printf (formatted output data) scanf (formatted string input) snprintf (formatted string copy) sprintf (formatted string copy) sscanf ( format string input) vfprintf (formatted output data to file) vfcanf (formatted string input) vprintf (formatted output data) VSCANF (formatted string input) vsnprintf (formatted string copy) vsprintf ( format string copy) vsscanf (formatted string input) (15) file and directory functionsAccess (determine if you have access to the file) Alphasort (sort directory structure alphabetically) ChDir (change the current working directory) chmod (change the file's permissions) Chown (change the owner of the file) Chroot (change the root directory) Closedir ( Close directory) Fchdir (change current working directory) fchmod (change file permissions) Fchown (change file owner) Fstat (get file status by file descriptor) ftruncate (change file size) ftw (Traverse directory tree) get_current _dir_name (get current working directory) GETCWD (get current working directory) GETWD (get current working directory) lchown (change file owner) Link (make File connection) Lstat (get file status by file descriptor) NFTW (Traverse directory tree ) opendir (Open Directory) Readdir (read directory) Readlink (gets the file that the symbolic connection refers to) Realpath (convert relative directory path to absolute path) remove (delete file) rename (change file name or location) Rewinddir (Resets the location of the read directory to the Beginning) Scandir (read specific directory data) Seekdir (sets the location of the next read directory) stat (get file status) symlink (establish file symbol connection) Telldir (get directory stream read location) truncate (change file size) umask (set permissions mask when creating a new file) unlink (delete file) utime (modify file access time and change time) utimes (modify file access and change time) (16) signal functionAlarm (Set signal transfer alarm) Kill (send signal to the specified process) pause (let the process pause until the signal appears) psignal (list signal description and specified string) raise (signal to current process) sigaction (query or Set signal processing mode) Sigaddset (adds a signal to the signal set) Sigdelset (removes a signal from the signal set) Sigemptyset (initializes the signal set) Sigfillset (adds all the signals to the signal set) Sigismember ( Test whether a signal has been added to the signal set) signal (Set signal processing mode) Sigpause (pause until the signal arrives) sigpending (query for a stalled signal) Sigprocmask (query or set signal matte) Sigsuspend ( Pause until signal arrives) sleep (let process pause execution for a while) isdigit (test character is Arabic numerals) (17) Error handling functionFerror (check file stream for errors) perror (Print out error reason information string) Streror (a description string that returns the cause of the error) (18) Pipeline correlation functionMKFIFO (establish named pipe) pclose (Close pipe I/O) pipe (build pipeline) Popen (establish pipeline I/O) (+) soket correlation functionAccept (socket connection) bind (socket) connect (establish socket) endprotoent (end of Read of network protocol data) Endservent (end reading of network service data) GETHOSTBYADDR (acquisition of network data by IP address) gethostbyname (acquisition of network data by host name) Getprotobyname (acquisition of protocol data by network protocol name) Getprotobynumber ( The protocol data obtained by the Network protocol number) Getprotoent (Access to Network protocol data) Getservbyname (data obtained by name for network services) Getservbyport (data obtained from the network service according to the port number) Getservent ( Access to the Host Network Service data) getsockopt (Get socket status) herror (print out the network error reason information string) Hstrerror (a description string that returns the cause of the network error) Htonl (converts 32-bit host character order to network character order) Htons (converts 16-bit host character order to network character order) Inet_addr (converts network address to network binary number) Inet_aton (converts network address to network binary number) Inet_ntoa (converts a network binary number to a network address) Listen (wait for connection) Ntohl (converts 32-bit network character order to host character order) Ntohs (converts 16-bit network character order to host character order) recv (receives data via socket) Recvfrom (receives data via socket) recvmsg ( Receive data via socket) send (via socket data) SENDMSG (socket transmitted data) SendTo (via socket data) setprotoent (Open Network Protocol data file) Setservent ( Open the data file for the Host Network Service) setsockopt (set socket state) shutdown (terminating socket communication) socket (set up a socket communication) (20) process communication (IPC) functionsFtok (convert file path and plan designator to Systemcvipckey) Msgctl (Control information queue operation) Msgget (establish information queue) MSGRCV (read information from information queue) msgsnd (send information to information queue) Semctl ( Control signal Queue operation) Semget (configuration signal queue) SEMOP (signal Processing) Shmat (attach shared memory) Shmctl (operation to control shared memory) SHMDT (detach shared memory) Shmget (Configure shared memory) (21) Recording functionCloselog (Close information record) Openlog (ready to do information logging) syslog (logs information to system log file) (22) environment variable functionGETENV (Get environment variable content) putenv (change or increase environment variable) setenv (change or increase environment variable) unsetenv (Clear environment variable contents) (23) Regular ExpressionsRegcomp (compile regular expression string) Regerror (Error reason to get regular search) Regexec (search for regular expression) RegFree (frees memory used by regular expression) (24) dynamic functionDlclose (Close dynamic function library file) dlerror (Dynamic function error handling) Dlopen (open dynamic function library file) Dlsym (search for dynamic functions from shared objects) (25) Other functionsGetopt (Parse command line arguments) Isatty (determines whether the file descriptor is a terminal) select (I/O multi-work mechanism) Ttyname (returns a terminal name)

Linux C common functions

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.