Created
May 19, 2013 12:09
-
-
Save gjb2048/5607476 to your computer and use it in GitHub Desktop.
For Using C Unions on a Raspberry Pi -> https://www.youtube.com/watch?v=Q-uwhWtfy2I
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> | |
union | |
{ | |
unsigned int i; | |
unsigned char c; | |
} aunion; | |
int main() | |
{ | |
aunion.i = 42; | |
printf("The answers are %d and %c\nWhy is that?\n", aunion.i, aunion.c); | |
printf("Unions are a facinating way of manipulating memory content\n"); | |
printf("But can be dangerous, which is why you will not find them in Java\n"); | |
printf("What is happening with the union 'aunion'?\n\n"); | |
printf("And like the last video, this is fast to compile\n"); | |
printf("But with Java you can take the .class file and run it on anything\n"); | |
printf("with a a Java Virtual Machine.\n"); | |
return aunion.i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment