常用的C函式

2021-07-23 05:02:12 字數 821 閱讀 7925

c常用字串函式

1、strstr

功能:從字串 str1 中尋找 str2 第一次出現的位置(不比較結束符null),如果沒找到則返回null。

2、strchr

功能:查詢字串中首次出現字元 ch 的位置,

返回首次出現 ch 的位置的指標,如果 str 中不存在 ch 則返回null。

3、strcpy

功能:把 src 所指由null結束的字串複製到 dest 所指的陣列中。

src 和 dest 所指記憶體區域不可以重疊且 dest 必須有足夠的空間來容納 src 的字             符串。返回指向 dest 結尾處字元(null)的指標。

4、strcat

功能:把 src 所指字串新增到 dest 結尾處(覆蓋dest結尾處的'\0')並新增'\0'。

src 和 dest 所指記憶體區域不可以重疊且 dest 必須有足夠的空間來容納 src 的字串。

返回指向 dest 的指標。

5、strcmp

功能:比較字串str1和str2。

6、strlen

功能:計算字串 str 的長度,

返回 str 的長度,不包括結束符null。(注意與 sizeof 的區別)

字元資料的輸入輸出

1、putchar

功能:向終端輸出乙個字元,可以是字元型變數也可以是整型變數,形式為putchar(c)

2、getchar

功能:從終端輸入乙個字元,getchar函式沒有引數,函式的值就是從輸入裝置得到的字元,getchar函式只能接收乙個字元而且字元可賦給乙個字元變數或者整型變數

C 常用函式

1 datetime 數字型 system.datetime currenttime new system.datetime 1.1 取當前年月日時分秒 currenttime system.datetime.now 1.2 取當前年 int 年 currenttime.year 1.3 取當前月 ...

常用c 函式

字串是不是數字 static int isnumber const char z,int realnum z if realnum realnum 0 找到第乙個不是數字的位置 while isdigit z if z if realnum realnum 1 if z e z e if realn...

c 常用函式

1 datetime 數字型 system.datetime currenttime new system.datetime 1.1 取當前年月日時分秒 currenttime system.datetime.now 1.2 取當前年 int 年 currenttime.year 1.3 取當前月 ...