Common functions:
Function name strcpy
Function copies one string to another
Original function char *strcpy(char *destin, char *source);
Example
char str[10];
char *str1="abcde";
strcpy(str,str1);
str contains "abcde"
This copies str1 to str
Function name strncpy
The function copies up to n characters in the string src to the character array dest (it does not stop copying when it encounters NULL like strcpy, but waits until n characters are collected before starting copying), and returns a pointer to dest. Note that it will overwrite previous characters.
Original function char *strncpy(char *dest, char *src,n);
Example
str[10]="abcdef",str1[10]="12345";
strncpy(str,str1,3); then str contains "123def"
Function name strcat
Function string concatenation function
Usage: char *strcat(char *destin, char *source);
Example
str[10]="abcdef",str1[10]="12345";
strcat(str,str1); then str contains "abcde12345"
Function name strcmp
Function string comparison
usage
intstrcmp(char *str1, char *str2);
If two strings are equal, return 0;
Example
Function name strlen
Function strlen function finds the length of a string. It counts from the beginning of the string until it encounters the first ''. If you only define it without assigning an initial value, the result is uncertain. It will count from the beginning of the string until it encounters a ''.
usage
Example
Function name strnicmp
This function compares a part of a string to another string, regardless of case.
Usage: strnicmp(char *str1, char *str2, unsigned maxlen);
For example, strnicmp(str1,str2,3) compares the first three characters of the latter string with the former string. If the characters are greater than the former, -1 is returned; if the characters are less than the former, 1 is returned; if the characters are equal, 0 is returned.
Function name stricmp
Function to compare two strings in a case-insensitive manner (don't understand)
Usage: int stricmp(char *str1, char *str2);
Example
Function name strcmpi
This function compares one string to another, regardless of case.
Usage: int strcmpi(char *str1, char *str2);
Example
Function name strrev
Function string reversal
Usage: char *strrev(char *str);
Example
Function name strtod
Function to convert a string into a double value
Usage: double strtod(char *str, char **endptr);
Description Convert the initial string of numbers into double type
Example
char input[90],*end;
gets(input);
double value=strtod(intput,&end);
Function name strtol
Function to convert a string to a long integer
Usage: longstrtol(char *str, char **endptr, int base);
Example
Function name
strupr
Function to convert lowercase letters in a string to uppercase letters
Usage: char *strupr(char *str);
Example
Function name strchr
This function finds the first occurrence of a given character in a string.
Usage: char *strchr(char *str, char c);
Example
Function name strcspn
This function finds the first segment with a given character set in a string.
Usage: int strcspn(char *str1, char *str2);
Example
Function name strdup
The function copies the string to the newly created location
Usage: char *strdup(char *str);
Example
Function name strerror
The function returns a pointer to an error message string.
Usage: char *strerror(int errnum);
Example
Function name strnset
This function sets all characters in a string to the specified characters.
Usage: char *strnset(char *str, char ch, unsigned n);
Example
Function name strpbrk
This function searches for characters in a given character set in a string.
Usage: char *strpbrk(char *str1, char *str2);
Example
Function name strrchr
This function finds the last occurrence of a specified character in a string.
Usage: char *strrchr(char *str, char c);
Example
Function name strstr
This function finds the first occurrence of a specified string in a string.
Usage: char *strstr(char *str1, char *str2);
Example
Function name strtok
This function searches for words separated by the delimiter specified in the second string.
Usage: char *strtok(char *str1, char *str2);
Example
Function name swab
Function swap byte
Usage: void swab (char *from, char *to, int nbytes);
Example
Previous article:#include<ctype.h> contains the function description
Next article:#include<stdlib.h> contains the function description
Recommended ReadingLatest update time:2024-11-17 14:54
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- IT outsourcing industry is making efforts in India to "overtake on the curve" in the field of artificial intelligence
- 【Portable Environmental Status Detector】OLED Screen Display Driver
- Topmicro Intelligent Module Case Engineering Collection
- 【UFUN Learning】Chapter 5 SD Card Test
- Introduction and working principle of humidity sensitive capacitor (humicap)
- An electric mosquito swatter actually has so many circuits. Have you learned all of them?
- How to draw the graph of the complex number solution of X^2+1=0 in the coordinate system? Can anyone help me? Thank you.
- Web page control 430 single chip microcomputer
- Bicycle modification series: code table
- Subform button display problem