[問題] C file processing的檔案到底存在哪裡

看板C_and_CPP (C/C++)作者 (拍玄)時間10年前 (2016/01/04 06:37), 10年前編輯推噓2(205)
留言7則, 2人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) OS X Xcode 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 只有stdio.h 問題(Question): 使用資料存取的檔案時,找不到檔案到底存在哪 餵入的資料(Input): none 預期的正確結果(Expected Output): 恩...是生出一個叫oldname.txt的檔案吧 錯誤結果(Wrong Output): 找不到檔案 程式碼(Code):(請善用置底文網頁, 記得排版) #include <stdio.h> int main(void) { unsigned int account; char name[30]; double balance; FILE *cfPtr; if ((cfPtr = fopen("oldname.txt", "w"))==NULL) { puts("File could not be opened"); } else { puts("Enter the account, name, and balance."); puts("Enter EOF to end input"); scanf("%d%29s%lf",&account, name, &balance); while(!feof(stdin)){ fprintf(cfPtr,"%d %s %.2f\n",&account,name,&balance); scanf("%d%29s%lf",&account,name,&balance); } } return 0; } 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.114.217.59 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1451860674.A.691.html ※ 編輯: rareone (140.114.217.59), 01/04/2016 06:39:04

01/04 07:29, , 1F
我覺得你寫支程式 system("ls"); 看看比較快
01/04 07:29, 1F

01/04 07:30, , 2F
基本上它會在所謂的「目前工作目錄」裡
01/04 07:30, 2F

01/04 07:30, , 3F
但當你從 IDE 裡執行時那是哪裡各 IDE 有所不同
01/04 07:30, 3F

01/04 07:31, , 4F
那這樣不如直接執行一個能告訴你目前目錄所在地的指令
01/04 07:31, 4F

01/04 07:31, , 5F
ls 是其一, pwd 也可以用
01/04 07:31, 5F

01/04 07:32, , 6F
(pwd 全名就是 print working directory, "印出工作目錄")
01/04 07:32, 6F

01/04 10:09, , 7F
謝謝LP大,我去Google 看看
01/04 10:09, 7F
文章代碼(AID): #1MYQB2QH (C_and_CPP)
文章代碼(AID): #1MYQB2QH (C_and_CPP)