Strcat意思

strcat是C語言中的一個函式,是string concatenation(字元串拼接)的縮寫。這個函式的作用是將一個字元串變數(源字元串)的所有字元連線到另一個字元串變數(目標字元串)的尾部,覆蓋目標字元串的剩餘部分。

函式原型如下:

char *strcat(char *dest, const char *src);

參數說明:

函式返回值: 函式返回目標字元串 dest 的地址。

示例:

#include <stdio.h>
#include <string.h>

int main() {
    char dest[100] = "Hello "; // 目標字元串
    char src[] = "world!"; // 源字元串
    strcat(dest, src); // 將src字元串連線到dest字元串的尾部
    printf("%s\n", dest); // 輸出拼接後的字元串
    return 0;
}

輸出:

Hello world!

注意: