[語法] C++ 有合併字串的功能嗎?
我以前用過 VB
他可以用類似這種方式, 合併字串傳給 Function
例如:
Function printStr(str as String)
Debug.Pring(str)
End Function
Sub test()
Dim str="String"
printStr("This is a str" & str & ".")
End Sub
我知道 C 可以這樣用
void printStr(char *str) {
printf("%s\n",str);
}
void test(void){
char str[]="String";
char str2[80];
strcpy(str2,"This is a ");
strcat(str2,str);
strcat(str2,".");
printStr(str2);
}
C 或 C++ 有更直接的作法嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.34.17
推
04/16 12:09, , 1F
04/16 12:09, 1F
→
04/16 12:10, , 2F
04/16 12:10, 2F
推
04/16 12:14, , 3F
04/16 12:14, 3F
→
04/16 12:15, , 4F
04/16 12:15, 4F
推
04/16 12:19, , 5F
04/16 12:19, 5F
→
04/16 13:12, , 6F
04/16 13:12, 6F
→
04/16 13:12, , 7F
04/16 13:12, 7F
→
04/16 13:13, , 8F
04/16 13:13, 8F
→
04/16 16:53, , 9F
04/16 16:53, 9F
→
04/16 16:53, , 10F
04/16 16:53, 10F
→
04/16 16:54, , 11F
04/16 16:54, 11F
→
04/16 16:54, , 12F
04/16 16:54, 12F
→
04/16 16:55, , 13F
04/16 16:55, 13F
→
04/16 16:56, , 14F
04/16 16:56, 14F
→
04/16 16:56, , 15F
04/16 16:56, 15F
→
04/16 16:57, , 16F
04/16 16:57, 16F
→
04/16 16:58, , 17F
04/16 16:58, 17F
→
04/19 04:04, , 18F
04/19 04:04, 18F
→
04/19 04:04, , 19F
04/19 04:04, 19F
→
04/19 04:05, , 20F
04/19 04:05, 20F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章