Just trying to print the square of a number using macros. Self explanatory C program :
#include <stdio.h>
#define numb(a) \
printf(#a * #a)
int main(void) {
int num;
printf("Enter a num: ");
scanf("%d",&num);
numb(num);
return 0;
}
Getting the error :
main.c: In function ‘main’:
main.c:4:14: error: invalid operands to binary * (have ‘char *’ and ‘char *’)
printf(#a * #a)
^
main.c:10:14:
square(num);
~
main.c:10:4: note: in expansion of macro ‘square’
square(num);
^~~~~~
How can I convert that char to int to sucessfully use the binary operator?