先用“input ”
输入出文本在系统内的正确路径如
F:\123.txt
然后在窗口显示出来文本内容.?
加以if的检测后缀并非为txt的东西打开无效.
路径错误也是.
并且打开后可以选择另存为路径..?

我在学VB..
FILE *input,*output;
char *name;
scanf("%s",name);
检查文件名,错误则提示后return 0;
if((input=fopen(name,"r"))==EOF) { 提示错误 return 0; }
while-printf
scanf("%s",name);
output=fopen(name,"w");
while-fprintf
我也想问这方面的问题,如果输入在文本里面呢?
比如
input.txt:
0 0 1
我想以double格式读入到output.txt中,该如何呢?
我发现double格式读入后,输入output.txt不是0.00 0.000 1.000
这是我的代码:
#include "stdio.h"
#define IN 2
#define ON 1
#define N 4
struct traningdata_type
{
int input[IN];
int output[ON];
}traningdata[N];
int main(int argc, char* argv[])
{
FILE *fp_input;
FILE *fp_output;
int j;
fp_input=fopen("c:\\1.txt","rb");
if(fp_input==NULL) printf("cant open input file!");
fp_output=fopen("c:\\11.txt","wb");
if(fp_output==NULL) printf("cant open out file!");
for(int i=0;i<N;i++)
{
for(j=0;j<IN;j++)
fscanf(fp_input,"%f",&traningdata[i].input[j]);
for(j=0;j<ON;j++)
fscanf(fp_input,"%f",&traningdata[i].output[j]);
}
for(i=0;i<N;i++)
{
for(j=0;j<IN;j++)
fprintf(fp_output,"%f",traningdata[i].input[j]);
for(j=0;j<ON;j++)
fprintf(fp_output,"%f",traningdata[i].output[j]);
}
fclose(fp_input);
fclose(fp_output);
return 0;
}
[此贴子已经被作者于2006-11-23 19:40:10编辑过]