string.h 頭定義了一個(gè)變量的類型,操作字符數(shù)組的一個(gè)宏觀和各種功能。
以下是在頭string.h中定義的變量類型:
S.N. | 變量和說(shuō)明 |
---|---|
1 |
size_t 這是一個(gè)無(wú)符號(hào)整數(shù)類型的sizeof關(guān)鍵字的結(jié)果。 |
以下是在頭string.h中定義的宏:
S.N. | 宏觀與說(shuō)明 |
---|---|
1 |
NULL 這個(gè)宏是一個(gè)空指針常量的值。 |
以下是頭string.h中定義的功能:
S.N. | 函數(shù)及說(shuō)明 |
---|---|
1 |
void *memchr(const void *str, int c, size_t n) 搜索第一次出現(xiàn)的字符c(unsigned char類型)的前n個(gè)字節(jié)的字符串參數(shù)str指向。 |
2 |
int memcmp(const void *str1, const void *str2, size_t n) 比較str1和str2的前n個(gè)字節(jié)。 |
3 |
void *memcpy(void *dest, const void *src, size_t n) 從src復(fù)制n個(gè)字符到dest。 |
4 |
void *memmove(void *dest, const void *src, size_t n) 另一個(gè)函數(shù)來(lái)復(fù)制n個(gè)字符到str1。 |
5 |
void *memset(void *str, int c, size_t n) 復(fù)制字符c(unsigned char類型)的前n個(gè)字符的字符串參數(shù)str指向。 |
6 |
char *strcat(char *dest, const char *src) 追加src指向的字符串到dest指向的字符串的結(jié)束。 |
7 |
char *strncat(char *dest, const char *src, size_t n) 追加src指向字符串結(jié)尾的字符串指向dest中最多n個(gè)字符長(zhǎng)。 |
8 |
char *strchr(const char *str, int c) 搜索第一次出現(xiàn)的字符串中的字符c(unsigned char類型)參數(shù)str指向。 |
9 |
int strcmp(const char *str1, const char *str2) 比較字符串str1指向指向的字符串str2。 |
10 |
int strncmp(const char *str1, const char *str2, size_t n) str1和str2的前n個(gè)字節(jié)相比。 |
11 |
int strcoll(const char *str1, const char *str2) 比較字符串str1的STR2。其結(jié)果是依賴于位置LC_COLLATE設(shè)置。 |
12 |
char *strcpy(char *dest, const char *src) 復(fù)制字符串src指向到dest。 |
13 |
char *strncpy(char *dest, const char *src, size_t n) 副本最多n個(gè)字符的字符串src指向到dest。 |
14 |
size_t strcspn(const char *str1, const char *str2) 計(jì)算str1的起始段的長(zhǎng)度完全包含在str2中的字符。 |
15 |
char *strerror(int errnum) 搜索一個(gè)內(nèi)部數(shù)組的錯(cuò)誤編號(hào)差錯(cuò)編號(hào),并返回一個(gè)指向一個(gè)錯(cuò)誤消息字符串。 |
16 |
size_t strlen(const char *str) 計(jì)算但不包括終止空字符的字符串str的長(zhǎng)度。 |
17 |
char *strpbrk(const char *str1, const char *str2) 查找字符串str1在str2中指定的任何字符相匹配的第一個(gè)字符。 |
18 |
char *strrchr(const char *str, int c) 參數(shù)str指向的字符串中的字符c(unsigned char類型)最后一次出現(xiàn)的搜索。 |
19 |
size_t strspn(const char *str1, const char *str2) 計(jì)算str1中的初始段完全包含在str2中的字符的長(zhǎng)度。 |
20 |
char *strstr(const char *haystack, const char *needle) 查找第一次出現(xiàn)的整個(gè)字符串針(不包括終止空字符)出現(xiàn)在字符串haystack中。 |
21 |
char *strtok(char *str, const char *delim) 中斷字符串str分隔分離成一系列的記號(hào)。 |
22 |
size_t strxfrm(char *dest, const char *src, size_t n) 轉(zhuǎn)換前n個(gè)字符的字符串src到校報(bào)的語(yǔ)言環(huán)境和將它們放置字符串dest。 |