慕課學習c筆記03 字串函式

2021-07-04 17:36:46 字數 752 閱讀 1012

常用的字串函式如下:

使用字串函式注意以下事項:

1、strlen()獲取字串的長度,在字串長度中是不包括『\0』而且漢字和字母的長度是不一樣的。比如:

2、strcmp()在比較的時候會把字串先轉換成ascii碼再進行比較,返回的結果為0表示s1和s2的ascii碼相等,返回結果為1表示s1比s2的ascii碼大,返回結果為-1表示s1比s2的ascii碼小,例如:

3、strcpy()拷貝之後會覆蓋原來字串且不能對字串常量進行拷貝,比如:

4、strcat在使用時s1與s2指的記憶體空間不能重疊,且s1要有足夠的空間來容納要複製的字串,如:

慕課玩兒轉swift筆記02 字串

1 運算子 int.max找出int型別的最大值,int.min找出int型別的最小值,swift是安全資料,int.max 1 溢位會報錯的。2 nil聚合運算子 a b 表示的是 a nil a nil a不是nil時解包a,若是nil時取b,要求a是可選性型別,b與a的解包型別一致 3 for...

演算法筆記03 字串01

1.字串的構造 string s0 hello world string s1 s0 s1拷貝s0 string s2 s0,8,3 s2從s0下標第8號開始拷貝3位,s2 rld string s3 hello world s3拷貝字串 string s4 hello world 5 s4拷貝he...

03 字串 基礎

1.string s new string abc 此時記憶體有兩個物件 stringpool裡 abc 堆空間 new string abc string s1 abc 因stringpool裡已經有 abc 物件,所以不會再產生,此時記憶體有兩個物件 string s2 new string a...