中易网

C语言高手,帮我的这个程序加个getch();让屏幕停住吧!谢谢!

答案:1  悬赏:50  
解决时间 2021-01-15 16:36
  • 提问者网友:疯孩纸
  • 2021-01-14 19:37
C语言高手,帮我的这个程序加个getch();让屏幕停住吧!谢谢!
最佳答案
  • 二级知识专家网友:夜余生
  • 2021-01-14 20:01
中间加那么多exit干嘛……程序结构就是这样被破坏的了……

#include
#include
#include
#define READ(ch) ch=getc(fp)
char ch;
int right=0;

FILE *fp;
struct struCH{
char ch;
struct struCH *next;
}struCH,*temp,*head,*shift;

void main(int argc,char *argv[]){
void E ();

void E1();

void T ();

void T1();

void F ();

int errnum=0,k=0,m=0,countchar=0,rownum;
int charerr=0;

if((fp=fopen(argv[1],"r"))==NULL)

{

printf("\n\tCan not open file %s,or not exist it!\n",argv[1]);

getch();exit(0);
}

else printf("\n\tSuccess open file: %s\n",argv[1]);

while(!feof(fp)){

READ(ch);

countchar++;

}

rewind(fp);

if(countchar==0){

printf("\t%s is a blank file!\n",argv[1]);

getch();exit(0);

}

while(k<(countchar-1)){

ch=getc(fp);

if(!(ch=='('||ch==')'||ch=='i'||ch=='+'||ch=='-'||ch=='*'||ch=='/'||ch=='#'||ch=='\n')){

charerr=1;errnum++;
}

k++;

}

rewind(fp);

if(charerr==1){

printf("\n\t%d Unindentify characters in file %s \n",errnum,argv[1]);

getch();exit(0);

}

for(rownum=1;m<(countchar-1);rownum++){

right=1;
shift=malloc(sizeof(struCH));

shift->next=NULL;
head=shift;

READ(ch);putchar(ch);m++;
while(ch!='\n'&&m<(countchar)){
temp=malloc(sizeof(struCH));
temp->ch=ch;
temp->next=NULL;
shift->next=temp;
shift=shift->next;
READ(ch);
if(m!=(countchar-1)) putchar(ch);

m++;
}
head=head->next;
shift=head;
putchar('\n');
E();
if(shift->ch=='#'&&right)
printf("%s Line %d:\t right expression!\n",argv[1],rownum);
else
printf("%s Line %d:\t error expression!\n",argv[1],rownum);
putchar('\n');
}
printf("Completed!\n");
fclose(fp);
getch();exit(0);
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息