[問題] fopen找不到 路徑已經檢查過

看板C_and_CPP (C/C++)作者 (800IM)時間14年前 (2011/11/29 17:13), 編輯推噓2(204)
留言6則, 4人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) VC++ 2010 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) #include <stdio.h> #include <iostream> #include <iomanip> #include <stdlib.h> 問題(Question): 檔案指標cfPtr為空 路徑也試過把input.txt放在C:\,給路徑"C:\input.txt",結果還是一樣。 餵入的資料(Input):預期的正確結果(Expected Output): 會讀到檔案 錯誤結果(Wrong Output): 檔案指標為空 程式碼(Code):(請善用置底文網頁, 記得排版) if( (cfPtr = fopen("input.txt","r")) == NULL) cout << "找不到檔案"; else { while(!feof(cfPtr)) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.122.197.50

11/29 17:16, , 1F
C:\\input.txt 或者在 檔案總管 中, 顯示副檔名
11/29 17:16, 1F

11/29 17:21, , 2F
剛試過樓上的方法,還是不行
11/29 17:21, 2F

11/29 17:22, , 3F
你隨便用 "w" 開一個檔, 就知道 input.txt 要放在哪邊
11/29 17:22, 3F

11/29 18:27, , 4F
Ya!樓上方法可以 原來被讀檔案名是input.txt.txt
11/29 18:27, 4F

11/29 22:01, , 5F
推板大3F的方法XD
11/29 22:01, 5F

11/29 22:02, , 6F
這叫反推回溯法XD
11/29 22:02, 6F
文章代碼(AID): #1ErA99x5 (C_and_CPP)
文章代碼(AID): #1ErA99x5 (C_and_CPP)