亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如下代碼,為什么會出現這個錯誤呢?求解釋!

如下代碼,為什么會出現這個錯誤呢?求解釋!

PHP
寶慕林4294392 2023-03-17 22:18:46
#include <stdio.h>#include <math.h>#include <ctype.h>#define NUMBER '0'#define MAXLEN 1000#define BUFSIZE 100int getch(void);void ungetch(int);int getline(char *);void push(double );double pop(void );void ungets(char *);double atof(char s[]);char buf[BUFSIZE];int bufp = 0;#define MAXVAL 100int sp = 0;double val[MAXVAL];main(int argc,char *argv[]){char s[MAXLEN];double op2;while(--argc > 0){ungets(" ");ungets(*++argv);switch(getline(s)){case NUMBER : push(atof(s));break;case '+' :push(pop() + pop());break;case '-' :op2 = pop();push(pop() - op2);break;case '*' :push(pop() * pop());break;case '/' :op2 = pop();if(op2 != 0.0)push(pop() / op2);else printf("error : zero divisor \n");break;default :printf("erro : unkown command %s\n",s);argc = 1;break;}}printf("\t%.8g\n",pop());return 0;}int getop(char s[]){int i,c;while((s[0] = c =getch()) == ' ' || c == '\t');s[1] = '\0';if( !isdigit(c) && c != '.')return c;i = 0;if(isdigit(c))while(isdigit(s[++i] = c = getch()));if(c == '.')while(isdigit(s[++i] = c =getch()));s[i] = '\0';if(c != EOF)ungetch(c);return NUMBER;}int getch(void){return (bufp > 0) ? buf[--bufp] : getchar();}void ungeth(int c){if(bufp >= BUFSIZE)printf("ungetch : too many characters\n");elsebuf[bufp++] = c;}void push(double f){if(sp < MAXVAL)val[sp++] = f;elseprintf("error: stack full , can't push %g\n");}double pop(){if(sp > 0)return val[--sp];else{printf("error: stack empty\n");return 0.0;}}double atof(char s[]){double val,power;int i,sign;for(i = 0; isspace(s[i]);i++);sign = (s[i] == '-') ? -1 : 1;if(s[i] == '+' ||s[i] == '-')i++;for(val = 0.0;isdigit(s[i]);i++)val = 10.0 * val + s[i] - '0';if(s[i] == '.'){i++;for(power = 1.0 ;isdigit(s[i]);i++){val = 10.0 * val + s[i] - '0';power *= 10.0 ;}}return sign * val / power;}
查看完整描述

2 回答

?
MMTTMM

TA貢獻1869條經驗 獲得超4個贊

有重復聲明的函數,如double atof(char s[]),把這個改個名,這個告警不會有了

查看完整回答
反對 回復 2023-03-21
?
呼如林

TA貢獻1798條經驗 獲得超3個贊

沒事的,你的程序沒有錯誤

查看完整回答
反對 回復 2023-03-21
  • 2 回答
  • 0 關注
  • 334 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號