Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define CREATE_LABEL2(A, B) A ## B
- #define CREATE_LABEL(A, B) CREATE_LABEL2(A, B)
- #define for_else(A) \
- for A \
- { \
- switch (0) \
- { \
- case 0:
- #define else_for \
- default: \
- goto CREATE_LABEL(__for_else_no_break_, __LINE__); \
- } \
- goto CREATE_LABEL(__for_else_break_, __LINE__); \
- CREATE_LABEL(__for_else_no_break_, __LINE__): \
- ;\
- } \
- if (0) \
- { \
- CREATE_LABEL(__for_else_break_, __LINE__): \
- ; \
- } \
- else
- int main(int argc, char **argv)
- {
- if (argc < 2)
- {
- fprintf(stderr, "invalid argument\n");
- return 1;
- }
- for_else ((int i = 0; argv[1][i] != 0; i++))
- {
- for_else ((volatile int j = 0; j <= i; j++))
- if (j > 5)
- {
- printf ("\n");
- break;
- }
- // /!\ this statement will be executed in the for_else loop ! better always use {}...
- printf("%d ", j);
- else_for
- printf("\n%d <= 5!\n", i);
- if (argv[1][i] == '!')
- {
- printf("'!' detected!\n");
- break;
- }
- }
- else_for
- {
- fprintf(stderr, "invalid argument\n");
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement