box-o-sand/oldstuff/PracticingC/gowrikumar/src/04b-macrodef.c

43 lines
811 B
C
Raw Normal View History

2011-06-18 18:28:00 +00:00
/**
* :author: Dan Buch (daniel.buch@gmail.com)
*/
#include <stdio.h>
#define f(a, b) a##b
#define g(a) #a
#define h(a) g(a)
#define border(c) \
for (int i = 0; i < 60; i++) { \
printf(c); \
} \
printf("\n");
int main()
{
printf("%s\n", h(f(1, 2)));
printf("%s\n", g(f(1, 2)));
printf("%s\n", g(printf("dogs rule cats drool\n")));
char * hambones = "Cats! " g(ham);
char * bonesham = "Meats! " g(bones);
char * tmp;
border("-");
printf("bonesham = %s\n", bonesham);
printf("hambones = %s\n", hambones);
border("-");
tmp = f(ham, bones);
f(ham, bones) = f(bones, ham);
f(bones, ham) = tmp;
printf("bonesham = %s\n", bonesham);
printf("hambones = %s\n", hambones);
return 0;
}
/* vim:filetype=c:fileencoding=utf-8
*/