主题:请教一下在DJGPP环境下的文件输出
下面是我写的2005年NOIP普及组第一题的源代码,在TC和WINTC下编译后执行都正常,可在DJGPP下编译也正常,可执行文件在运行后也能有输出文件,但是里面没有任何内容.请帮帮我,看一下到底是怎么回事,是源程序不对还是DJGPP没有设置好?小妹在这里谢谢各位大哥大姐了!!再有十来天就要参加复赛了,请各位无论如何帮帮我!!
#include<stdio.h>
main()
{
FILE *in,*out;
int num=0,a[10],high,i;
if((in=fopen("apple.in","r"))==NULL)
{
printf("cannot open the file");
exit(0);
}
fscanf(in,"%d %d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&high);
for(i=0;i<10;i++)
{
if(a[i]<=(high+30)) num++;
}
if((out=fopen("apple.out","w"))==NULL)
{
printf("cannot open");
exit(0);
}
fprintf(out,"%d",num);
fclose(in);
fclose(out);
}
#include<stdio.h>
main()
{
FILE *in,*out;
int num=0,a[10],high,i;
if((in=fopen("apple.in","r"))==NULL)
{
printf("cannot open the file");
exit(0);
}
fscanf(in,"%d %d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9],&high);
for(i=0;i<10;i++)
{
if(a[i]<=(high+30)) num++;
}
if((out=fopen("apple.out","w"))==NULL)
{
printf("cannot open");
exit(0);
}
fprintf(out,"%d",num);
fclose(in);
fclose(out);
}