作业帮 > 综合 > 作业

C语言出现for information on how you program can cause an asserti

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/10 12:28:24
C语言出现for information on how you program can cause an assertion failure
#include
#include
#include
#include
#include
#define MAX 100
typedef struct
{ char dm[5] ; /*产品代码*/
char mc[11] ; /*产品名称*/
int dj ; /*单价*/
int sl ; /*数量*/
long je ; /*金额*/
}PRO ;
PRO sell [MAX] ;
void ReadDat() ;
void WriteDat() ;
void SortDat()
{
int i,j;
PRO xy;
for(i=0;isell[j].je)
{xy=sell[i];sell[i]=sell[j];sell[j]=xy;}
}
}
main()
{
memset(sell,0,sizeof(sell)) ;
ReadDat() ;
SortDat() ;
WriteDat() ;
}
void ReadDat()
{
FILE *fp ;
char str[80],ch[11] ;
int i ;
fp = fopen("IN1.DAT","r") ;
for (i = 0 ; i < 100 ; i++)
{
fgets(str,80,fp) ;
memcpy(sell[i].dm,str,4) ;
memcpy(sell[i].mc,str + 4,10) ;
memcpy(ch,str + 14,4) ; ch[4] = 0 ;
sell[i].dj = atoi(ch) ;
memcpy(ch,str +18,5) ; ch[5] = 0 ;
sell[i].sl = atoi(ch) ;
sell[i].je = (long)sell[i].dj * sell[i].sl;
}
fclose(fp) ;
}
void WriteDat()
{
FILE *fp;
int i ;
fp = fopen("OUT1.DAT","w") ;
for(i = 0 ; i < 100 ; i++)
fprintf(fp,"%s %s %4d %5d %10ld\n",sell[i].dm,sell[i].mc,sell[i].dj,sell[i].sl,
sell[i].je) ;
fclose(fp) ;
}
C语言出现for information on how you program can cause an asserti
难道没人知道吗?