[問題] 二維陣列與sprintf的問題

看板C_and_CPP (C/C++)作者 (colin)時間12年前 (2013/11/04 14:20), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) linux 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) stdio.h 問題(Question): 原本的程式碼如下: sprintf(data,"%s %d %d %d %s",ctime(&timep),value[0],value[1],value[2],tmp); ctime(&timep)取系統的時間 value是gpio的值 int value[3]; tmp是uart的值 char tmp[255]; 一開始,得到一個uart的輸入值,沒有問題 現在我要輸入2個uart的值 char tmp[2][255]; 改成 sprintf(data,"%s %d %d %d %s %s",ctime(&timep),value[0],value[1],value[2] ,tmp[0][255],tmp[1][255]); 結果執行程式就當掉了, 不知道這裡的tmp[0][255],tmp[1][255]要什麼改,會比較好 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.120.103.214 linotwo:tmp[0] 謝謝,問題解決了 11/04 14:27

11/04 14:28, , 1F
還有你最後多了一個 %s
11/04 14:28, 1F
不小心多打了 一個%s ※ 編輯: cld123 來自: 59.120.103.214 (11/04 14:35) ※ 編輯: cld123 來自: 59.120.103.214 (11/04 14:54)
文章代碼(AID): #1ITpp6ED (C_and_CPP)
文章代碼(AID): #1ITpp6ED (C_and_CPP)