[問題] 'const wchar_t [6]' to 'TCHAR'

看板C_and_CPP作者 (幫幫)時間12年前 (2013/08/05 08:25), 編輯推噓0(004)
留言4則, 2人參與, 最新討論串1/2 (看更多)
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) VC++ (VS2008) 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 不知道是哪邊設定錯誤?是unicode的關係嗎? 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): error C2440: '=' : cannot convert from 'const wchar_t [6]' to 'TCHAR' 程式碼(Code):(請善用置底文網頁, 記得排版) TCHAR* tchShmName; for(int i=1;i<=2;i++) { tchShmName[i] = TEXT("Shm%d",i); } 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.99.166.2

08/05 23:38, , 1F
:) 你沒發現你要塞的東西太大了嗎?
08/05 23:38, 1F

08/05 23:39, , 2F
還有,你為tchShmName配置記憶體空間了嗎?
08/05 23:39, 2F

08/06 05:10, , 3F
不如就用 string 吧 http://codepad.org/MZaYOWuu
08/06 05:10, 3F

08/06 05:11, , 4F
注意陣列的第一個元素是從 0 算起
08/06 05:11, 4F
文章代碼(AID): #1H_s6Hsz (C_and_CPP)
文章代碼(AID): #1H_s6Hsz (C_and_CPP)