字串處理函式的用法案例

2021-08-14 04:50:13 字數 1048 閱讀 5576

/*

字串處理函式:

>庫函式:string.h

>函式原型:

char *strcpy( char *s1, const char *s2 );//copy字串函式,返回s1的值,s2->s1;

char *strncpy( char *s1, const char *s2, size_t n );//s2->s1 至多複製n個字元

char *strcat( char *s1, const char *s2 );//connect字串函式,返回s1的值,s1+s2;

char *strncat( char *s1, const char *s2 , size_t n );//s1 + s2中的至多n個字元.

//字串比較函式:

int strcmp( const char *s1, const char *s2);

int strncmp( const char *s1, const char *s2, size_t n );

//字串查詢函式:

char *strchr( const char *s, int c );

char *strrchr( const char *s, int c );

char *strstr( char *s1, const char *s2 );

暫時不講述:在"安全的c程式設計"中介紹

//字串分解函式

char *strtok( char *s1, const char *s2 );

13:28

*/#include

#include

#define size 100

int main()

/****

****

****

****

woyoukexiaolidezhi

woyoukexiaolidezhi

manman

iaolidezhi

iaolidezhi

請按任意鍵繼續. . .

*/

C atoi 函式用法案例詳解

目錄 atoi 函sfvneugz數將數字格式的字串轉換為整數型別。例如,將字串 12345 轉換成數字12345。該函式的格式為 int atoi const char str 其中,引數str是要轉換的字串,返回值是轉換後的整數。在 2 格式 中提到,atoi 函式的引數是要轉換的字串。該字串的...

mysql的字串處理函式用法

1.locate函式 locate substr,str 返回子串 substr 在字串 str 中第一次出現的位置。如果子串 substr 在 str 中不存在,返回值為 0。如果substr或str為null,則返回null。從1開始 例如 mysql select locate bar foo...

Powershell 字串處理案例

有一張excel 收集了計算機名和ip位址,另外一張表有計算機名,需要找出這張表中計算機名對應的ip位址。定義函式get likecontentinfofunction get likecontentinfo result export csv path outcsvpath notypeinfor...