-
-
Save k0kubun/1719cbccd7738c02e5b8d7d1c12d7469 to your computer and use it in GitHub Desktop.
Tested on Oracle Developer Studio 12.5 and Visual Studio 2013
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdbool.h> | |
struct point { | |
int x, y; | |
}; | |
void print_point(struct point arg) { | |
printf("arg: x = %d, y = %d\n", arg.x, arg.y); | |
} | |
int main(void) { | |
/* // comments */ | |
// comment | |
/* boolean type in stdbool.h */ | |
bool boolean = true; | |
if (!boolean) return 1; | |
/* mixed declarations and code */ | |
int sum = 0; | |
for (int i = 1; i < 5; i++) { | |
sum += i; | |
} | |
printf("sum: %d\n", sum); | |
/* designated initializers */ | |
struct point pos = { .x = 1, .y = 2 }; | |
printf("pos: x = %d, y = %d\n", pos.x, pos.y); | |
/* compound literals */ | |
print_point((struct point){ .x = 3, .y = 4 }); | |
/* relaxed constraints on aggregate and union initialization (non-constant aggregate initializer) */ | |
int arr[] = { sum }; | |
printf("arr: %d\n", arr[0]); | |
/* trailing comma allowed in enum declaration */ | |
enum hello { | |
HELLO, | |
WORLD, | |
}; | |
printf("hello: %d, world: %d\n", HELLO, WORLD); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment