編寫乙個函式,刪除乙個字串的一部分

2021-08-11 02:22:28 字數 629 閱讀 8830

函式的原型如下:

int substr(char *str,const char *substr)

函式應該首先判斷substr是否出現在str中,如果它並未出現,函式返回值為0;如果出現,函式返回值為1;str中儲存刪除後的字串。

實驗**如下:

#define _crt_secure_no_warnings 1

#include

#include

#include

int my_substr(char *str, const char *substr)

else

}if (*substr_start == '\0')

start++;

}return0;}

int main()

實驗結果:測試1:

測試2:

編寫乙個字串處理函式 練習

字串1 swift nslayoutconstraint 字串2 tfiws tniartsnoctuoyalsn 按上邊字串1轉換到字串2 的規律,編寫乙個字串處理函式。方法1 header content type text html charset utf8 str swift nslayou...

在乙個字串中尋找另外乙個字串

在乙個字串中尋找另外乙個字串 public class text foundit true break test system.out.println foundit?found it didn t find it 該段程式有點難以理解,主要就是if語句的理解,if searchme.charat ...

php判斷乙個字串包含另乙個字串

a 58252,58253 如果 a 中存在 b,則為 true 否則為 false。b 58253 if strpos a,b false else 查詢字串在陣列中出現的次數 array array 1,hello 1,world hello 11 計算 string在 array 需為陣列 中...