c程序出错,file:fscanf.c Line:54 expression:stream!=NULL 很急于把这个问题解决,希望谁可以帮我解决这
DebugAssertionFailed!Program:D:\10.11\tiaokonggaokai\Debug\tiaokongfuben2.exefile:fsc...
Debug Assertion Failed!
Program: D:\10.11\tiaokonggaokai\Debug\tiaokongfuben2.exe
file:fscanf.c
Line:54
expression:stream!=NULL
For information on how your program can cause an assertion failure,see the Visual C++ documentation on asserts.
#include "Stdio.h"
#include "Conio.h"
#include "String.h"
#define no 16
#define num 1500
#define fe 56
void main()
{
void solve(FILE *fp,char *p);
FILE *fp,*fq;
int i,k,f=0;
int max=0;
char name[20],filename[fe][10];
char out[17]={"outdata"};
char *p;
fp=fopen("D:\10.11\tiaokonggaokai\filename.txt","r");
for(i=0;i<fe;i++)
{
fscanf(fp,"%s",filename[i]);
f++;
if(feof(fp))fclose(fp);
}
for(k=0;k<f;k++)
{
p=filename[k];
fp=fopen(filename[k],"r");
fscanf(fp,"%s",name);
fq=fopen(strcat(out,filename[k]),"w");
fprintf(fq,"%s\n",name);
fprintf(fq,"时间 开盘 最高 涨幅 最低 收盘 利润 \n");
fclose(fq);
solve(fp,p);
}
}
void solve(FILE *fp,char *p)
{
struct PRO
{ char time[10]; /*日期*/
float kaipan; /*开盘*/
float high; /*最高价*/
float zhangfu; /*涨幅*/
float low; /*最低价*/
float shoupan; /* 收盘价*/
float profit;
};
struct PRO data[2];
struct PRO satisfydata[16];
FILE **fp1;
FILE *fp2;
char str[17]={"outdata"};
int i,max;
fscanf(fp,"%s %f %f %f %f %f ",data[0].time,&data[0].kaipan,&data[0].high,&data[0].zhangfu,&data[0].low,&data[0].shoupan);
fp1=fp;
fscanf(fp1,"%s %f %f %f %f %f ",data[1].time,&data[1].kaipan,&data[1].high,&data[1].zhangfu,&data[1].low,&data[1].shoupan);
if(100*(data[1].kaipan-data[0].shoupan)/data[0].shoupan>4)
for(i=0;i<2;i++)
{
strcat(satisfydata[i].time,data[i].time);
satisfydata[i].kaipan=data[i].kaipan;
satisfydata[i].high=data[i].high;
satisfydata[i].zhangfu=data[i].zhangfu;
satisfydata[i].low=data[i].low;
satisfydata[i].shoupan=data[i].shoupan;
}
max++;
for(i=2;i<no;i++)
{
fscanf(fp1,"%s %f %f %f %f %f",satisfydata[i].time,&satisfydata[i].kaipan,&satisfydata[i].high,&satisfydata[i].zhangfu,&data[i].low,&data[i].shoupan);
if(feof(fp))fclose(fp);
}
for(i=1;i<no;i++)
satisfydata[i].profit=100*(satisfydata[i].high-satisfydata[1].kaipan)/satisfydata[1].kaipan;
satisfydata[0].profit=0;
fp2=fopen(strcat(str,p),"a");
for(i=0;i<max;i++)
{
fprintf(fp,"%s %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f \n",satisfydata[i].time,satisfydata[i].kaipan,satisfydata[i].high,satisfydata[i].zhangfu,satisfydata[i].low,satisfydata[i].shoupan,satisfydata[i].profit);
}
solve(fp,p);
}
QQ443654884,没有财富值了,加QQ或许能给热心人满意的东西。 展开
Program: D:\10.11\tiaokonggaokai\Debug\tiaokongfuben2.exe
file:fscanf.c
Line:54
expression:stream!=NULL
For information on how your program can cause an assertion failure,see the Visual C++ documentation on asserts.
#include "Stdio.h"
#include "Conio.h"
#include "String.h"
#define no 16
#define num 1500
#define fe 56
void main()
{
void solve(FILE *fp,char *p);
FILE *fp,*fq;
int i,k,f=0;
int max=0;
char name[20],filename[fe][10];
char out[17]={"outdata"};
char *p;
fp=fopen("D:\10.11\tiaokonggaokai\filename.txt","r");
for(i=0;i<fe;i++)
{
fscanf(fp,"%s",filename[i]);
f++;
if(feof(fp))fclose(fp);
}
for(k=0;k<f;k++)
{
p=filename[k];
fp=fopen(filename[k],"r");
fscanf(fp,"%s",name);
fq=fopen(strcat(out,filename[k]),"w");
fprintf(fq,"%s\n",name);
fprintf(fq,"时间 开盘 最高 涨幅 最低 收盘 利润 \n");
fclose(fq);
solve(fp,p);
}
}
void solve(FILE *fp,char *p)
{
struct PRO
{ char time[10]; /*日期*/
float kaipan; /*开盘*/
float high; /*最高价*/
float zhangfu; /*涨幅*/
float low; /*最低价*/
float shoupan; /* 收盘价*/
float profit;
};
struct PRO data[2];
struct PRO satisfydata[16];
FILE **fp1;
FILE *fp2;
char str[17]={"outdata"};
int i,max;
fscanf(fp,"%s %f %f %f %f %f ",data[0].time,&data[0].kaipan,&data[0].high,&data[0].zhangfu,&data[0].low,&data[0].shoupan);
fp1=fp;
fscanf(fp1,"%s %f %f %f %f %f ",data[1].time,&data[1].kaipan,&data[1].high,&data[1].zhangfu,&data[1].low,&data[1].shoupan);
if(100*(data[1].kaipan-data[0].shoupan)/data[0].shoupan>4)
for(i=0;i<2;i++)
{
strcat(satisfydata[i].time,data[i].time);
satisfydata[i].kaipan=data[i].kaipan;
satisfydata[i].high=data[i].high;
satisfydata[i].zhangfu=data[i].zhangfu;
satisfydata[i].low=data[i].low;
satisfydata[i].shoupan=data[i].shoupan;
}
max++;
for(i=2;i<no;i++)
{
fscanf(fp1,"%s %f %f %f %f %f",satisfydata[i].time,&satisfydata[i].kaipan,&satisfydata[i].high,&satisfydata[i].zhangfu,&data[i].low,&data[i].shoupan);
if(feof(fp))fclose(fp);
}
for(i=1;i<no;i++)
satisfydata[i].profit=100*(satisfydata[i].high-satisfydata[1].kaipan)/satisfydata[1].kaipan;
satisfydata[0].profit=0;
fp2=fopen(strcat(str,p),"a");
for(i=0;i<max;i++)
{
fprintf(fp,"%s %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f \n",satisfydata[i].time,satisfydata[i].kaipan,satisfydata[i].high,satisfydata[i].zhangfu,satisfydata[i].low,satisfydata[i].shoupan,satisfydata[i].profit);
}
solve(fp,p);
}
QQ443654884,没有财富值了,加QQ或许能给热心人满意的东西。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询