Possible Duplicate:
How to stringify an expression in C
I hope I can find some solution of my issue here.
I want to add the hex numbers defined in ADD1 and need to put the same in *str
in string form.
This is only a example, to prove its possibility first. I am actually doing the same in a header file.
#include <stdio.h>
#define XMK_STR(x) #x
#define MK_STR(x) XMK_STR(x)
#define ADD1 0x6000+0x10
main()
{
char *str = "START " MK_STR(ADD1) "\n";
printf(str);
}
No. You can't perform calculations using preprocessor. It's essentially a text-replacer.
You can use sprintf()
and print the added result into str
for that you can use ADD1
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With