-
Notifications
You must be signed in to change notification settings - Fork 662
Expand file tree
/
Copy pathc.c
More file actions
93 lines (77 loc) · 1.23 KB
/
c.c
File metadata and controls
93 lines (77 loc) · 1.23 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Comments
// Single-line comment
/*
* Multi-line
* comment
*/
#include <stdio.h>
#include <stdbool.h>
#define MAX_BUFFER 1024
#ifndef MY_HEADER_H
#define MY_HEADER_H
#endif
// Numbers
42;
3.14;
.5;
1e10;
1.5e-3;
0xff;
0xFF;
0b1010;
0o77;
42ul;
3.14f;
// Constants
true;
false;
NULL;
// Strings and characters
'a';
'\n';
"double quotes with escape: \" \n \t \\";
// Control flow keywords
int main(int argc, char *argv[]) {
if (argc > 1) {
// ...
} else if (argc == 0) {
// ...
} else {
// ...
}
for (int i = 0; i < 10; i++) {
if (i == 5) continue;
if (i == 8) break;
}
while (false) { }
do { } while (false);
switch (argc) {
case 1:
break;
default:
goto end;
}
end:
return 0;
}
// Other keywords and structures
struct Point {
int x;
int y;
};
typedef union {
char c;
double d;
} DataUnion;
enum Color { RED, GREEN, BLUE };
extern int global_var;
static const int MAX_RETRIES = 5;
volatile int hardware_register;
register int fast_loop_counter;
// C99/C11 specific keywords
_Atomic int atomic_counter;
_Bool is_active;
_Noreturn void die(void);
// Function calls
printf("hello\n");
sizeof(struct Point);