Skip to content

Commit fab1e79

Browse files
committed
Create goto_in_c.c
1 parent 0127592 commit fab1e79

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

c/misc/goto_in_c.c

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
#include <stdio.h>
3+
4+
#define A 1
5+
#define B 0
6+
#define C 0
7+
8+
int main() {
9+
// fail switch
10+
if (!A) {
11+
goto exit;
12+
}
13+
if (!B) {
14+
goto restart_B;
15+
}
16+
if (!C) {
17+
goto restart_C;
18+
}
19+
// no fails
20+
return 0;
21+
22+
restart_B:
23+
printf("%s\n", "restarting B");
24+
25+
restart_C:
26+
printf("%s\n", "restarting C");
27+
28+
exit:
29+
printf("%s\n", "exiting");
30+
31+
// some fails
32+
return -1;
33+
}

0 commit comments

Comments
 (0)