| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 406 人关注过本帖
标题:运行程序出错 求大侠指点~
只看楼主 加入收藏
hxfml
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-7-21
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
运行程序出错 求大侠指点~
编译无问题 运行出错提示如下
Debug Assertion Failed!
Program:k:\Debug\1.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.
(press retry to debug the application)

程序如下:
#include <stdio.h>
#define MAX 200
int a[MAX],b[MAX],cnt=0;
void writeDat();

void jsVal()
{int i,j;               
int a1,a2,a3,a4;      
int temp;              
for(i=0;i<200;i++)   
{
a4=a[i]/1000;     
a3=a[i]%1000/100;
a2=a[i] %100/10;   
a1=a[i] %10;        
        if(a4%2!=0 && a3%2!=0 && a2%2!=0 && a1%2!=0)
 
{
b[cnt]=a[i];
cnt++;        
}
}
for(i=0;i<cnt-1;i++)  
for(j=i+1;j<cnt;j++)
if(b[i]<b[j])
{
temp=b[i];
b[i]=b[j];
b[j]=temp;
}    
}

void readDat()
{
int i;
FILE *fp;
fp=fopen("IN1.DAT","r");
for(i=0;i<MAX;i++)
fscanf(fp,"%d",&a[i]);
fclose(fp);
}

void main()
{
int i;
readDat();
jsVal();
printf("满足条件的数=%d\n",cnt);
for(i=0;i<cnt;i++)
printf("%d\n",b[i]);
printf("\n");
writeDat();
}

void writeDat()
{
FILE *fp;
int i;
fp=fopen("out1.dat","w");
fprintf(fp,"%d\n",cnt);
for(i=0;i<cnt;i++)
fprintf(fp,"%d\n",b[i]);
fclose(fp);
}

先谢过各位大侠了~~
搜索更多相关主题的帖子: 运行 
2009-07-21 13:57
y_afu
Rank: 2
等 级:论坛游民
帖 子:17
专家分:62
注 册:2009-7-7
收藏
得分:20 
fp=fopen("IN1.DAT","r");
应该是找不到IN1.DAT文件。
2009-07-22 16:08
快速回复:运行程序出错 求大侠指点~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017389 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved