this might be a newbie question and I see something similar asked before, but I hope someone will help me. Below is a small (hopefully) illustrative code. I want to have two functions share some code. They will both have a test, which boils down to: if (int operator int). It should be possible to describe the operator with a pointer, and then use what the pointer points to in the test, shouldnt it?
func1(){
func3(1)
}
func2(){
func3(2);
}
func3(int type){
char *op;
int value1;
int value2;
switch (type){
case 1:
op = ">";
value1 = 1;
value2 = 3;
break;
case 2:
op = "=";
value1 = 2;
value2 = 5;
break;
}
if (value1 *op value2){
do something
}
}
I find that > is converted to 62 (decimal) in a text to binary calculator, but this prints out 60 - why?
char *p = "<";
printf("%d\n", *p);