我知道我可以有一個語句,這樣的strcat來連接A和B,而無需實際改變a或b
strcat(a, b);
int alen = strlen(a);
printf("a and b concatenated = %s and its length is %d\n", a, alen);
不過,我想保留一個,所以我想用更多的東西是這樣的:
strcat(a, b);
int xlen = strlen(x);
printf("a and b concatenated = %s and its length is %d\n", x, xlen);
如何用strcat修復第一行,以便將a和b連接成x?
謝謝你,這是很簡單的。 – tinkerton101 2015-04-05 19:56:26
有一個重要的細節總是要檢查。具體而言,如果SIZE1和SIZE2與strlen(a)和strlen(b)相關,那麼x的長度足以保存strlen(a)+ strlen(b)+1 – user3629249 2015-04-06 22:10:35