]> Pileus Git - ~andy/sfvlug/blobdiff - c/src/cpp.c
Add C notes.
[~andy/sfvlug] / c / src / cpp.c
diff --git a/c/src/cpp.c b/c/src/cpp.c
new file mode 100644 (file)
index 0000000..3518371
--- /dev/null
@@ -0,0 +1,35 @@
+#include <stdio.h>
+
+#define ANSWER        42
+
+#define COUNTER       counter++
+
+#define DONT          printf("Don't"
+#define DO            " do "
+#define THIS          "this!\n");
+
+#define HELLO1(name)  printf("Hello, %s\n", name)
+
+#define HELLO2(name)  printf("Hello, " #name "\n")
+
+int main()
+{
+       int counter = 0;
+
+       printf("The answer is %d.\n", ANSWER);
+       printf("\n");
+
+       printf("The counter is %d.\n", COUNTER);
+       printf("The counter is %d.\n", COUNTER);
+       printf("The counter is %d.\n", COUNTER);
+       printf("\n");
+
+       DONT DO THIS
+       printf("\n");
+
+       HELLO1("Andy");
+       HELLO2(Andy);
+       HELLO2("Andy");
+
+       return 0;
+}