]> Pileus Git - ~andy/sfvlug/blob - c/src/cpp.c
Add C notes.
[~andy/sfvlug] / c / src / cpp.c
1 #include <stdio.h>
2
3 #define ANSWER        42
4
5 #define COUNTER       counter++
6
7 #define DONT          printf("Don't"
8 #define DO            " do "
9 #define THIS          "this!\n");
10
11 #define HELLO1(name)  printf("Hello, %s\n", name)
12
13 #define HELLO2(name)  printf("Hello, " #name "\n")
14
15 int main()
16 {
17         int counter = 0;
18
19         printf("The answer is %d.\n", ANSWER);
20         printf("\n");
21
22         printf("The counter is %d.\n", COUNTER);
23         printf("The counter is %d.\n", COUNTER);
24         printf("The counter is %d.\n", COUNTER);
25         printf("\n");
26
27         DONT DO THIS
28         printf("\n");
29
30         HELLO1("Andy");
31         HELLO2(Andy);
32         HELLO2("Andy");
33
34         return 0;
35 }