作者Alf1 (LLee)
看板b98902HW
标题[计程] worksheet9
时间Tue Nov 24 18:32:52 2009
int main()
{
FILE *fp;
int i;
fp=fopen("test.txt", "w");
scanf("%d", &i);
while (!feof(stdin)) {
fprintf(fp,"%d\n", i);
scanf("%d", &i);
}
fclose(fp);
return 0;
}
//这是老师今天上课对於worksheet9的第一题写的
//所以资料夹里面现在产生一个test.txt
============================================
int function902()
{
FILE *fpin, *fpout;
int i;
fpin=fopen("test", "r");
fpout=fopen("test.1", "w");
while (!feof(fpin)) {
fscanf(fpin, "%d\n", &i);
fprintf(fpout,"%d\n", i);
}
return 0;
}
//这是针对第二题写的
//老师强调test不需要副档名
//但是资料夹里面只有test.txt这个档案
//并没有test这个档案
请问有人可以解答吗?
--
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.29.128
1F:→ mimi9126:是因为fscanf里面多了一个'\n' 11/24 19:36
2F:→ Alf1:应该跟 \n 无关 11/25 18:56
3F:推 s864372002:test.txt是第一个程式产生的,test不会自己凭空生出来 11/25 19:00
4F:→ s864372002:要测试的话请自己新开一个叫test的档案。 11/25 19:00