vc++编译可通过,但运行时报错file:fgetc.c line:41,哪位大神给看下····
程序如下#include<stdio.h>#defineA8chartime();intt(intx,inty);charop();voidmain(){charch[9...
程序如下
#include <stdio.h>
#define A 8
char time();
int t(int x,int y);
char op();
void main()
{
char ch[99999];
int a=0;
FILE *fp;
fp=fopen("C:\Users\gd\Desktop\程序\aa.txt","r");
if (fp==NULL)
{
printf("/n Can not open the file,press any key to exit!/n");
}
else ch[a]=fgetc(fp);
while(ch[a]!=EOF)
{
a++;
ch[a]=fgetc(fp);
}
}
char time(char *sh)
{
int x,y;
x,y=t(x,y);
for(;sh[x]!=EOF;x++)
if(sh[x]!=0)y++;
return y;
}
int t(int x,int y)
{
int a,b,c,d,e,f,m,l;
printf("请输入起始时间 : : ");
scanf("%d:d%:d%",&a,&b,&c);
printf("请输入终止时间 : : ");
scanf("%d:d%:d%",&d,&e,&f);
m=a*3600+b*60+c-1;
l=d*3600+e*60+f-1;
x=m,y=l;
return x,y;
}
char op(char op[])
{
char str1[999999],str2[99999],str3[99999],str4[99999],str5[99999],str6[99999],str7[99999],str8[99999];
int b=0,c=0;
int t1,t2,t3,t4,t5,t6,t7,t8;
while(op[c]!=EOF)
{str1[b]=op[c];
str2[b]=op[c+1];
str3[b]=op[c+2];
str4[b]=op[c+3];
str5[b]=op[c+4];
str6[b]=op[c+5];
str7[b]=op[c+6];
str8[b]=op[c+7];
b++;
c=c+A-1;
}
t1=time(str1);
t2=time(str2);
t3=time(str3);
t4=time(str4);
t5=time(str5);
t6=time(str6);
t7=time(str7);
t8=time(str8);
printf("一到八号柜在规定时间内的照明时间分别为,%d,%d,%d,%d,%d,%d,%d,%d,",t1,t2,t3,t4,t5,t6,t7,t8);
return 0;
} 展开
#include <stdio.h>
#define A 8
char time();
int t(int x,int y);
char op();
void main()
{
char ch[99999];
int a=0;
FILE *fp;
fp=fopen("C:\Users\gd\Desktop\程序\aa.txt","r");
if (fp==NULL)
{
printf("/n Can not open the file,press any key to exit!/n");
}
else ch[a]=fgetc(fp);
while(ch[a]!=EOF)
{
a++;
ch[a]=fgetc(fp);
}
}
char time(char *sh)
{
int x,y;
x,y=t(x,y);
for(;sh[x]!=EOF;x++)
if(sh[x]!=0)y++;
return y;
}
int t(int x,int y)
{
int a,b,c,d,e,f,m,l;
printf("请输入起始时间 : : ");
scanf("%d:d%:d%",&a,&b,&c);
printf("请输入终止时间 : : ");
scanf("%d:d%:d%",&d,&e,&f);
m=a*3600+b*60+c-1;
l=d*3600+e*60+f-1;
x=m,y=l;
return x,y;
}
char op(char op[])
{
char str1[999999],str2[99999],str3[99999],str4[99999],str5[99999],str6[99999],str7[99999],str8[99999];
int b=0,c=0;
int t1,t2,t3,t4,t5,t6,t7,t8;
while(op[c]!=EOF)
{str1[b]=op[c];
str2[b]=op[c+1];
str3[b]=op[c+2];
str4[b]=op[c+3];
str5[b]=op[c+4];
str6[b]=op[c+5];
str7[b]=op[c+6];
str8[b]=op[c+7];
b++;
c=c+A-1;
}
t1=time(str1);
t2=time(str2);
t3=time(str3);
t4=time(str4);
t5=time(str5);
t6=time(str6);
t7=time(str7);
t8=time(str8);
printf("一到八号柜在规定时间内的照明时间分别为,%d,%d,%d,%d,%d,%d,%d,%d,",t1,t2,t3,t4,t5,t6,t7,t8);
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询