c下的不常用的字串操作

2021-08-04 06:59:08 字數 590 閱讀 1797

1)strnicmp,strncmpi,_strnicmp

原型:extern int strnicmp(char *s1,char * s2,int n);

用法:#include 功能:比較字串s1和s2的前n個字元但不區分大小寫。
引數說明:s1,s2 字串,n 要比較的前n個字元
說明:strncmpi是到strnicmp的巨集定義

當s1s2時,返回值》0

2)strchr
原型:extern char *strchr(char *str,char character)
用法:#include
功能:從字串str中查詢字元character第一次出現的地方
引數說明:str為乙個字串的指標,character為乙個待查詢字元
說明:還有一種格式char *strchr( const char *

string

, int 

c),這裡字串是以int型給出的

返回指向第一次出現字元character位置的指標,如果沒找到則返回null。

c 常用的字串操作

int atoi const char str 函式char numstr 12 int val atoi numstr 標頭檔案 stdlib.h stdio.h char strtok char str,const char delim 分解字串str為一組字串,delim為分隔符。char s...

c 字串常用操作

class class1 trim方法,刪除字串中的空格或其它字元 string stre stra.trim console.writeline stre stre 使用 顯示引號 和反斜線 string strf c windows system32 console.writeline strf...

字串的常用操作

總結substring 2 表示從第2個字元開始,擷取到末尾 substring 2,4 表示從第2個字元開始,往後擷取 4 2 個字元 string str 1314 string s1 str.substring 2 314 string s2 str.substring 2 4 31strin...