rpn電卓のプログラムを作成していて、
conflicting types for 'strtok'
implicit declaration of function 'isdigit' [-Wimplicit-function-declaration]
というエラーメッセージがでていて解決方法が分かりません。
また、プログラムに足りていないところがあれば教えていただきたいです。
プログラムの条件としてfgetsとstrtok関数を使うこと。というのがあります。
C言語
1#include <stdio.h> 2#include <stdlib.h> 3#include <string.h> 4 5int stack[100]; 6int top = 0; 7char *strtok(char*s1,char*s2); 8 9int push(int x); 10int pop(); 11 12int push(int x) 13{ 14 if (top == 100) 15 return -1; 16 stack[top] = x; 17 top++; 18 return 1; 19} 20 21int pop() 22{ 23 --top; 24 return stack[top]; 25} 26int main(void) 27{ 28 int a,b; 29 char str[80],*tok; 30 char delim[]=","; 31 fgets(str,80,stdin); 32 tok=strtok(str,delim); 33 while (tok != NULL) 34 { 35 if (isdigit(*tok)) 36 { 37 push(atoi(tok)); 38 } 39 else 40 { 41 a = pop(); 42 b = pop(); 43 switch (*tok) 44 { 45 case '+': 46 push(b + a); 47 break; 48 case '-': 49 push(b - a); 50 break; 51 case '*': 52 push(b * a); 53 break; 54 case '/': 55 push(b / a); 56 default: 57 fprintf(stderr, "operator expected\n"); 58 exit(0); 59 } 60 } 61 tok = strtok(NULL,delim); 62 } 63 printf("%f\n", pop()); 64 65 return 0; 66} 67

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。