[問題] C++的字串路徑
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Linux, vim, gcc
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
cstring, iostream, fstream
問題(Question):
argv[2]是user會輸入的檔名
讀的檔案放在 HW1/inputs/
main.cpp放在 HW1/src/main.cpp
餵入的資料(Input):
argv[2]是user會輸入的檔名
預期的正確結果(Expected Output):
希望能將user輸入的檔名讀進來
錯誤結果(Wrong Output):
compile不會過
相關訊息如下:
warning: missing terminating " character
error: missing terminating " character
initializer fails to determine size of ‘filePath’
程式碼(Code):(請善用置底文網頁, 記得排版)
http://ideone.com/pineDc
補充說明(Supplement):
code是我自己寫的
看錯誤訊息應該是我字串處理不當
請高手給予指點
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.118.150.2
※ 編輯: wsx100 來自: 140.118.150.2 (02/26 20:01)
→
02/26 20:02, , 1F
02/26 20:02, 1F
→
02/26 20:02, , 2F
02/26 20:02, 2F
→
02/26 20:03, , 3F
02/26 20:03, 3F
感謝兩位的幫忙
compile過了
可是檔案還沒有成功讀入
假設user給的檔名是 test.txt
我的filePath = ./inputs/test.txt
用這個路徑去open是失敗的?
想再請問是不是這樣的路徑還是錯的呢?
執行檔在 HW1/result/
test.txt在 HW1/inputs/
謝謝
※ 編輯: wsx100 來自: 140.118.150.2 (02/26 20:22)
→
02/26 21:12, , 4F
02/26 21:12, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章