45 lines
1.0 KiB
C
45 lines
1.0 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define size_of(arr) (sizeof(arr) / sizeof(*arr))
|
|
|
|
#define DEBUG(x, args...) \
|
|
fprintf(stderr, "ERROR: %s:%u\n" x, __FILE__, __LINE__, ##args)
|
|
|
|
void cleanup1() { printf("cleanup1\n"); }
|
|
void cleanup2() { printf("cleanup2\n"); }
|
|
void cleanup3() { printf("cleanup3\n"); }
|
|
|
|
int main(int argc, char *argv[]) {
|
|
atexit(cleanup1);
|
|
int i = 10;
|
|
// while (i --> 0) {
|
|
// printf("%d\n", i);
|
|
// }
|
|
while ((i--) > 0) {
|
|
printf("%d\n", i);
|
|
}
|
|
|
|
int array[200];
|
|
printf("array[200] len: %ld\n", size_of(array));
|
|
DEBUG("Our array should be 200! %ld\n", size_of(array));
|
|
atexit(cleanup2);
|
|
|
|
int num = 11;
|
|
//(num & 1) ? printf("odd\n") : printf("even\n");
|
|
char *res = (num & 1) ? "odd" : "even";
|
|
printf("%s\n", res);
|
|
// if (num & 1) {
|
|
// printf("odd\n");
|
|
// } else {
|
|
// printf("even\n");
|
|
// }
|
|
|
|
atexit(cleanup3);
|
|
int x = 5;
|
|
printf("%d >> 1 = %d\n", x, x >> 1);
|
|
printf("%d << 1 = %d\n", x, x << 1);
|
|
|
|
return 0;
|
|
}
|