为什么在TC2.0下运行不能生成out.dat文件?

来源:百度知道 编辑:UC知道 时间:2024/05/27 18:58:27
#include <conio.h>
#include <stdio.h>

unsigned fun ( unsigned w )
{
unsigned t,s=0,s1=1,p=0;
t=w;
while(t>10)
{
if(t/10)
p=t%10;
s=s+p*s1;
s1=s1*10;
t=t/10;
}
return s;
}

main( )
{
unsigned x;
FILE *out;

printf ( "Enter a unsigned integer number : " );
scanf ( "%u", &x );
printf ( "The original data is : %u\n", x );
if ( x<10 )
printf ("Data error !");
else
printf ( "The result : %u\n", fun ( x ) );
out = fopen("out.dat", "w");
fprintf(out, "%u" , fun(28));
fclose(out);
}
在TC2.0下我按CTRL+F9运行,但是却没有得到out.dat文件。请大家教教我。如何才能生成out.dat这文件。
在output文件夹里只找到*.exe和*.obj文件。没有找到out.dat文件。

这个问题是跟你的文件和TC所在的位置有关的!
当你使用TC编写完代码后,在TC里编译运行的话,这时会使用TC的output设置来存放文件,也就是说,生成的文件有可能不在与程序文件同一目录!仔细找一下TC的output目录里有没有!估计是在里面!