I´m relatively new in programming and I was trying to define a macro called OPERATORS in the following way:
#define OPERATORS {'+', '-','*', '/', '%', '^'}
Run Code Online (Sandbox Code Playgroud)
This, with the purpose of making the following programm:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define OPERATORS {'+', '-','*', '/', '%', '^'}
int isOperator (char c) {
if(c!=OPERATORS)
return 0;
return 1;
}
int main(){
printf("%d", isOperator('+'));
printf("%d", isOperator('j'));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
要知道字符 c 是否是运算符。但是我在编译器方面遇到了问题,我确定这与宏的声明有关。所以我的问题是:
如何使用一组运算符定义宏以及我应该如何使用它?因为我几乎可以肯定,要将变量与宏进行比较,应该以不同的方式进行 抱歉我的无知,非常感谢您!!!