阿摩線上測驗 登入

申論題資訊

試卷:100年 - 100年高等三級暨普通考普通_資訊處理#29521
科目:程式設計
年份:100年
排序:0

題組內容

四、

申論題內容

⑴請問下列 C 程式片段執行後,s1 的內容為何?(7 分)
strcpy(s1,"tire-bouchon");
strcpy(&s1[4],"d-or-wi");
strcat(s1, "red?");

詳解 (共 1 筆)

詳解 提供者:hchungw

在 C 程式片段執行後,s1 的內容會是 'tired-or-winred?'。這個結果是由以下步驟產生的:
strcpy(s1,"tire-bouchon") 將 s1 初始化為 "tire-bouchon"。
strcpy(&s1[4],"d-or-wi") 會將 s1 從索引 4 開始的部分替換為 "d-or-wi",因此 s1 變為 "tired-or-wi"。
strcat(s1, "red?") 會在 s1 的結尾處加上 "red?",因此最終的 s1 為 "tired-or-winred?"。