轉載鏈接:http://blog.csdn.net/smf0504/article/details/52055971
函數原型
extern char *strcat(char *dest,char *src);
函數用法
#include <string.h>
在 C++ 中,則存在於 <cstring> 頭文件中。
函數功能
把 src 所指字符串添加到 dest 結尾處(覆蓋 dest 結尾處的'\0')。
函數說明
src 和 dest 所指內存區域不可以重疊且 dest 必須有足夠的空間來容納 src 的字符串。結果返回指向 dest 的指針。
Example
// strcat.c
#include <syslib.h> #include <string.h>
int main() { char d[20] = "GoldenGlobal"; char* s = "View"; clrscr(); strcat(d,s); printf("%s",d); getchar(); return 0; }
// strcat.cpp
#include <iostream> #include <cstring> #include <cstdlib>
using namespace std; int main() { char d[20] = "GoldenGlobal"; char* s = "View"; system("cls"); strcat(d,s); cout << d << endl; system("pause"); return 0; }
程序執行結果為:GoldenGlobalView
