作者rareone (拍玄)
看板C_and_CPP
标题[问题] C file processing的档案到底存在哪里
时间Mon Jan 4 06:37:49 2016
开发平台(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://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1451860674.A.691.html
※ 编辑: rareone (140.114.217.59), 01/04/2016 06:39:04
1F:推 LPH66: 我觉得你写支程式 system("ls"); 看看比较快 01/04 07:29
2F:→ LPH66: 基本上它会在所谓的「目前工作目录」里 01/04 07:30
3F:→ LPH66: 但当你从 IDE 里执行时那是哪里各 IDE 有所不同 01/04 07:30
4F:→ LPH66: 那这样不如直接执行一个能告诉你目前目录所在地的指令 01/04 07:31
5F:→ LPH66: ls 是其一, pwd 也可以用 01/04 07:31
6F:→ LPH66: (pwd 全名就是 print working directory, "印出工作目录") 01/04 07:32
7F:推 watermeter: 谢谢LP大,我去Google 看看 01/04 10:09