1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
// instead of struct [Name] { ... };
// typedef struct { ... } Name;
// Takes advantage of anomynous structs from the previous example
// and typedef accepting any expression
typedef struct {
int x;
int y;
} Point;
int main(int argc, char* argv[]) {
Point p1 = {.x = 5, .y = 9 };
Point p2 = {.x = 9 };
printf("(p1.x, p1.y) == (%d, %d)\n", p1.x, p1.y);
printf("(p2.x, p2.y) == (%d, %d)\n", p2.x, p2.y);
return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */
|
© Copyright 2022 Alexander J. Quinn This content is protected and may not be shared, uploaded, or distributed.