Exe8 自己寫的字串操作函式

2021-05-21 15:07:00 字數 555 閱讀 6708

1. char* strcat(char* dest,char* src)

#include

#include

char* mystrcat(char* des,char* src)

int main()

2. char* strrev(char* str)

#include

#include

#include

void swap(char& a,char& b)

char* mystrrev(char* str)

3.char* mystrstr(char* str,char*substr)

#include

using namespace std;

char* mystrstr(char* str,char*substr)

while(*sp++==*bp++);

str+=1;

}return null;

}int main()

4.mystrstr(char* str1,char*str2)

自己寫的字串函式

include using namespace std define n 50 將字串src複製到desti void mystrcpy char desti,char src desti 0 比較字串大小 int mystrcmp char str1,char str2 return p1 p2 ...

自己寫的 字串函式strcpy

字串函式char stcpy char dest,const char src 是將原字串 src 的內容複製到 目的字串 dest 裡。但是strcpy 函式是乙個很危險的函式,如果需要複製源字串 src 的大小比目的字串 dest 大,呼叫函式的時候,並不會報錯,複製字串的時候,分配給目的字串的...

自己實現的字串操作函式

自己編寫實現字串相關的函式 包括四個基礎的字串操作函式strlen strcpy strcmp strcat 以及擴充套件的strstr 還有兩個操作記憶體的memcpy memmove define crt secure no warnings include include include 求字...