Last active
December 29, 2015 01:48
-
-
Save andrewjkerr/7595340 to your computer and use it in GitHub Desktop.
A few pointers on writing in C.
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
/* | |
* In C, you cannot do the following: | |
* for(int i = 0; i < 5; i++){ | |
* // do stuff | |
* } | |
* | |
* You must do the following: | |
*/ | |
void main( void ){ | |
int i; | |
for(i = 0; i < 5; i++){ | |
// do something 5 times! | |
} | |
} |
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
/* | |
* If you use a function 'b' in function 'a', you *must* either have 'b' ahead of 'a' in your code or do the following: | |
*/ | |
void b(int); | |
void main( void ){ | |
b(); | |
// do stuff yo | |
} | |
void b ( int x ){ | |
// woah you do some stuff here too! | |
} |
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
/* | |
* Here's a pointer on pointers :) | |
*/ | |
#define LATCH_ADDR 0x4000 | |
void main( void ){ | |
// let's write 0x22 to our latch! | |
unsigned int* latch = (unsigned int*) LATCH_ADDR; | |
*latch = 0x22; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment