Study on the second day

Today, I mainly learned the use of string functions,
including
1, strlen (arr) to find the length of the string, and read the number of characters in front of the string \0. The return value is an unsigned type, so note that the subtraction is also unsigned.
2. strcpy(arr1, arr2) copies the contents of arr2 to arr1, including \0, and the return value is the address of arr1.
3. Strcat(arr1, arr2) append function, append the content of arr2 to the back of arr1, the return value is the address of the starting element of arr1, you cannot append yourself.
4. Strcmp (arr1, arr2) 2 string comparisons, string comparison cannot use "==", the comparison method is character one for comparison, not the length of the string. If the character size appears, it is the comparison result. The return value is greater than 0, less than 0, and equal to 0
5. strncpy(arr1, arr2, num) copies the num bit of arr2 to arr1. If num is greater than the content of arr2, add \ 0,
6, strncat (arr1, arr2, num) append the num bit of arr2 to arr1, if num is greater than the content length of arr2, no need to add \0.
7. strncmp(arr1, arr2, num) compare arr1 and arr2 Num bits.
8. strstr(arr1, arr2) searches for arr2 string in arr1, that is, finds a substring. The return value is the first address of the substring found in arr1.
9. strtok(str,sep) divides the string in str according to the separator.
str is a string with a separator, sep is a set of separators that
will eliminate one separator when called once, the first call passes the address, and the latter passes NULL, the return value is the first address of the divided string.
Character operation
1, tolower() changes uppercase to lowercase
2. toupper() changes lowercase to uppercase

Guess you like

Origin blog.51cto.com/15085121/2593579