字串函式大全

2021-04-24 17:04:52 字數 4811 閱讀 2100

函式名: stpcpy

功  能: 拷貝乙個字串到另乙個

用  法: char *stpcpy(char *destin, char *source);

程式例:

#include

#include

int main(void)

函式名: strcat

功  能: 字串拼接函式

用  法: char *strcat(char *destin, char *source);

程式例:

#include

#include

int main(void)

函式名: strchr

功  能: 在乙個串中查詢給定字元的第乙個匹配之處/

用  法: char *strchr(char *str, char c);

程式例:

#include

#include

int main(void)

函式名: strcmp

功  能: 串比較

用  法: int strcmp(char *str1, char *str2);

看asic碼,str1>str2,返回值 > 0;兩串相等,返回0

程式例:

#include

#include

int main(void)

函式名: strncmpi

功  能: 將乙個串中的一部分與另乙個串比較, 不管大小寫

用  法: int strncmpi(char *str1, char *str2, unsigned maxlen);

程式例:

#include

#include

int main(void)

函式名: strcpy

功  能: 串拷貝

用  法: char *strcpy(char *str1, char *str2);

程式例:

#include

#include

int main(void)

函式名: strcspn

功  能: 在串中查詢第乙個給定字符集內容的段

用  法: int strcspn(char *str1, char *str2);

程式例:

#include

#include

#include

int main(void)

函式名: strdup

功  能: 將串拷貝到新建的位置處

用  法: char *strdup(char *str);

程式例:

#include

#include

#include

int main(void)

函式名: stricmp

功  能: 以大小寫不敏感方式比較兩個串

用  法: int stricmp(char *str1, char *str2);

程式例:

#include

#include

int main(void)

函式名: strerror

功  能: 返回指向錯誤資訊字串的指標

用  法: char *strerror(int errnum);

程式例:

#include

#include

int main(void)

函式名: strcmpi

功  能: 將乙個串與另乙個比較, 不管大小寫

用  法: int strcmpi(char *str1, char *str2);

程式例:

#include

#include

int main(void)

函式名: strncmp

功  能: 串比較

用  法: int strncmp(char *str1, char *str2, int maxlen);

程式例:

#include

#include

int  main(void)

函式名: strncmpi

功  能: 把串中的一部分與另一串中的一部分比較, 不管大小寫

用  法: int strncmpi(char *str1, char *str2);

程式例:

#include

#include

int main(void)

函式名: strncpy

功  能: 串拷貝

用  法: char *strncpy(char *destin, char *source, int maxlen);

程式例:

#include

#include

int main(void)

函式名: strnicmp

功  能: 不注重大小寫地比較兩個串

用  法: int strnicmp(char *str1, char *str2, unsigned maxlen);

程式例:

#include

#include

int main(void)

函式名: strnset

功  能: 將乙個串中的所有字元都設為指定字元

用  法: char *strnset(char *str, char ch, unsigned n);

程式例:

#include

#include

int main(void)

函式名: strpbrk

功  能: 在串中查詢給定字符集中的字元

用  法: char *strpbrk(char *str1, char *str2);

程式例:

#include

#include

int main(void)

函式名: strrchr

功  能: 在串中查詢指定字元的最後乙個出現

用  法: char *strrchr(char *str, char c);

程式例:

#include

#include

int main(void)

函式名: strrev

功  能: 串倒轉

用  法: char *strrev(char *str);

程式例:

#include

#include

int main(void)

函式名: strset

功  能: 將乙個串中的所有字元都設為指定字元

用  法: char *strset(char *str, char c);

程式例:

#include

#include

int main(void)

函式名: strspn

功  能: 在串中查詢指定字符集的子集的第一次出現

用  法: int strspn(char *str1, char *str2);

程式例:

#include

#include

#include

int main(void)

函式名: strstr

功  能: 在串中查詢指定字串的第一次出現

用  法: char *strstr(char *str1, char *str2);

程式例:

#include

#include

int main(void)

函式名: strtod

功  能: 將字串轉換為double型值

用  法: double strtod(char *str, char **endptr);

程式例:

#include

#include

int main(void)

函式名: strtok

功  能: 查詢由在第二個串中指定的分界符分隔開的單詞

用  法: char *strtok(char *str1, char *str2);

程式例:

#include

#include

int main(void)

函式名: strtol

功  能: 將串轉換為長整數

用  法: long strtol(char *str, char **endptr, int base);

程式例:

#include

#include

int main(void)

函式名: strupr

功  能: 將串中的小寫字母轉換為大寫字母

用  法: char *strupr(char *str);

程式例:

#include

#include

int main(void)

函式名: swab

功  能: 交換位元組

用  法: void swab (char *from, char *to, int nbytes);

程式例:

#include

#include

#include

char source[15] = "rfna koblrna d";

char target[15];

int main(void)

C 字串函式大全

函式名 stpcpy 功 能 拷貝乙個字串到另乙個 用 法 char stpcpy char destin,char source 程式例 include include int main void 函式名 strcat 功 能 字串拼接函式 用 法 char strcat char destin,...

ASP字串函式大全

len len string varname 返回字串內字元的數目,或是儲存一變數所需的位元組數。trim trim string 將字串前後的空格去掉 ltrim ltrim string 將字串前面的空格去掉 rtrim rtrim string 將字串後面的空格去掉 midmid string...

php字串函式大全

addcslashes 為字串裡面的部分字元新增反斜線轉義字元 addslashes 用指定的方式對字串裡面的字元進行轉義 bin2hex 將二進位制資料轉換成十六進製制表示 chop rtrim 的別名函式 chr 返回乙個字元的ascii碼 chunk split 按一定的字元長度將字串分割成小...