关于生成文件的问题
我打算写一个程序完成这样的功能,从一个文本文件中读出要生成的文件名的字符串,然后生成该文件。程序如下:#include <stdio.h>
#include <string.h>
#include <process.h>
void main()
{
FILE *fp1;
FILE *outfp[10];
int n = 0;
int o = 0;
char seg[100]="0";
char name[30];
fp1 = fopen("conf.txt", "r");
if (fp1 == NULL)
{
printf("open file fail!");
exit(0);
}
while (fp1 == EOF)
{
fgets(seg,sizeof(seg),fp1);
sscanf(seg,"%s",name);
outfp[n]=fopen(name,"w");
if (outfp[n] == NULL)
{
printf("open file fail!");
exit(0);
}
n++;
}
while (o <=n)
{
fclose(outfp[o]);
o++;
}
}//end of main
其中conf.txt文件的内容如下:
"o5021000.txt"
"o5022000.txt"
"o5023000.txt"
"o5024000.txt"
"o5025000.txt"
"o5026000.txt"
"o5027000.txt"
"o5028000.txt"
编译、执行,不能生成相应的文件。请问错在哪里?请指教,谢谢!