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或许能给热心人满意的东西。
展开
 我来答
dl510186192
2010-11-17
知道答主
回答量:15
采纳率:0%
帮助的人:1.9万
展开全部
fscanf(fp,"%s",filename[i]);
错了...
用 fputs(filename[i]),fp); 吧。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式