[問題] C file processing的檔案到底存在哪裡
開發平台(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
01/04 07:29, 1F
→
01/04 07:30, , 2F
01/04 07:30, 2F
→
01/04 07:30, , 3F
01/04 07:30, 3F
→
01/04 07:31, , 4F
01/04 07:31, 4F
→
01/04 07:31, , 5F
01/04 07:31, 5F
→
01/04 07:32, , 6F
01/04 07:32, 6F
推
01/04 10:09, , 7F
01/04 10:09, 7F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章