Skip to content

Instantly share code, notes, and snippets.

@daniel-packard
Last active March 18, 2016 20:01
Show Gist options
  • Save daniel-packard/fd67a58c6342119f85f3 to your computer and use it in GitHub Desktop.
Save daniel-packard/fd67a58c6342119f85f3 to your computer and use it in GitHub Desktop.
Demos some basic properties of struct assignments.
#include <stdio.h>
typedef struct {
int x;
int y;
} point_t;
void printPoint(point_t p) {
printf("X: %d, Y: %d\n", p.x, p.y);
}
int main (int argc, char* argv[]) {
point_t x1 = {.x=10, .y=20};
point_t x2 = {.x=30, .y=40};
x2 = x1;
printPoint(x1);
printPoint(x2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment