C语言拼接字符串 -- 使用strcat()函数
生活随笔
收集整理的這篇文章主要介紹了
C语言拼接字符串 -- 使用strcat()函数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
【頭文件】#include <string.h>
【原型】
char *strcat(char *dest, const char *src);【參數】: dest 為目標字符串指針,src 為源字符串指針。
strcat() 會將參數 src 字符串復制到參數 dest 所指的字符串尾部;dest 最后的結束字符 NULL 會被覆蓋掉,并在連接后的字符串的尾部再增加一個 NULL。
【注意】 dest 與 src 所指的內存空間不能重疊,且 dest 要有足夠的空間來容納要復制的字符串
【返回值】 返回dest 字符串起始地址。
【實例】連接字符串并輸出。
#include <stdio.h>#include <string.h>int main (){char str[80];strcpy (str,"these ");strcat (str,"strings ");strcat (str,"are ");strcat (str,"concatenated.");puts (str);return 0;}輸出結果:
these strings are concatenated.?
轉載于:https://www.cnblogs.com/lvchaoshun/p/5936168.html
總結
以上是生活随笔為你收集整理的C语言拼接字符串 -- 使用strcat()函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: http://blog.sina.com
- 下一篇: Git SSH Key 生成步骤