C語言拼接字串 -- 使用strcat()函式
阿新 • • 發佈:2019-02-05
【標頭檔案】#include <string.h>
【原型】
1 |
|
【引數】: dest 為目標字串指標,src 為源字串指標。
strcat() 會將引數 src 字串複製到引數 dest 所指的字串尾部;dest 最後的結束字元 NULL 會被覆蓋掉,並在連線後的字串的尾部再增加一個 NULL。
【注意】 dest 與 src 所指的記憶體空間不能重疊,且 dest 要有足夠的空間來容納要複製的字串
【返回值】 返回dest 字串起始地址。
【例項】連線字串並輸出。
1 2 3 4 5 6 7 8 9 10 11 12 |
(str);
|
輸出結果:
these strings are concatenated.