Last active
December 10, 2015 21:28
-
-
Save LambdaSix/4494795 to your computer and use it in GitHub Desktop.
Struct assignment.
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
$ gcc struct.c -o struct | |
$ ./struct | |
a.Bar: 1 | |
b.Bar: 2 | |
a.Bar: 2 | |
b.Bar: 1 |
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" | |
typedef struct Foo { | |
int Bar; | |
} Foo; | |
int main(int argc, char* argv[]) | |
{ | |
// Init them. Plus c as a swap buffer. | |
Foo a,b,c; | |
a.Bar = 1; | |
b.Bar = 2; | |
printf("a.Bar: %d\n", a.Bar); | |
printf("b.Bar: %d\n", b.Bar); | |
// Flip them. | |
c = a; | |
a = b; | |
b = c; | |
printf("a.Bar: %d\n", a.Bar); | |
printf("b.Bar: %d\n", b.Bar); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment