Created
June 10, 2015 08:22
-
-
Save orbitcowboy/2088de476935041057d7 to your computer and use it in GitHub Desktop.
How to concatenate two strings in a C macro?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define concat0(str1, str2) (str1 " " str2) | |
#define concat1(str1, str2) (#str1 " " #str2) | |
int main() | |
{ | |
printf("%s\n%s\n", | |
concat0 ("a","b"), | |
concat1 ("a","b")); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you, it works.