![]() |
C programming: How to insert a define inside a string |
Hello,
I have been searching for 2 hours how to put a #define inside a C string :
Example :
#define MYNAME john
printf("my name is ##MYNAME##")
Fast and accurate answer appreciated.
Hello Cybercinglet,
C String can be interrupted.
Example: string my_string="my name is" "john";
This has the same effect as "my name is john".
So use :
#define MYNAME "john"
printf("my name is" MYNAME); will work properly.
Regards.