-
Notifications
You must be signed in to change notification settings - Fork 15
/
ifdef.c
41 lines (34 loc) · 944 Bytes
/
ifdef.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
------------------------------------------------------------------------------------
Tutorial: #ifdef (if defined)
------------------------------------------------------------------------------------
*/
/*
We can check if a symbolic constant or a macro is defined using #ifdef
We can also use #if defined to do the same task.
*/
#include <stdio.h>
#define VALUE 1
int main(void)
{
#ifdef VALUE
printf("Value is defined\n");
#else
printf("Value is not defined\n");
#endif
}
/*
------------------------------------------------------------------------------------
Challenge: What does the following code output
#include <stdio.h>
#define UNIX 1
int main()
{
#ifdef UNIX
printf("UNIX specific function calls go here.\n");
#endif
printf("TechOnTheNet is over 10 years old.\n");
return 0;
}
------------------------------------------------------------------------------------
*/