strcpy()函數在C語言中用於將一個字串複製到另一個字串中。其使用方法為:宣告兩個字串變量,一個用於儲存目標字串,另一個用於儲存來源字串。初始化來源字串。呼叫strcpy()函數將來源字串複製到目標字串中。
strcpy函數在C語言中的用法
strcpy()函數在C語言中用於將一個字串複製到另一個字串中。其語法如下:
char *strcpy(char *dest, const char *src);
其中:
如何使用strcpy()函數?
範例程式碼:
#include <stdio.h> #include <string.h> int main() { char dest[20]; char src[] = "Hello World!"; strcpy(dest, src); printf("%s\n", dest); return 0; }
關鍵點:
以上是strcpy在c語言中怎麼用的詳細內容。更多資訊請關注PHP中文網其他相關文章!