diff options
| author | Geoff Liu <g@geoffliu.me> | 2015-01-18 13:07:39 -0700 | 
|---|---|---|
| committer | Geoff Liu <g@geoffliu.me> | 2015-01-18 13:07:39 -0700 | 
| commit | 31faf1a6a1c35802cf3676ec1a7f54d86411b566 (patch) | |
| tree | 5ccca54b8837fec9a8d6d60d2bda6db4162078e7 /c.html.markdown | |
| parent | 40c38c125b94430b518d7e402d595694149b7c53 (diff) | |
| parent | c053f1559bb357d9e8ced2452096bf3a95cc7ddb (diff) | |
Merge branch 'master' of github.com:geoffliu/learnxinyminutes-docs
Diffstat (limited to 'c.html.markdown')
| -rw-r--r-- | c.html.markdown | 14 | 
1 files changed, 8 insertions, 6 deletions
| diff --git a/c.html.markdown b/c.html.markdown index f44da38e..7670824a 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -26,13 +26,15 @@ Multi-line comments look like this. They work in C89 as well.  Multi-line comments don't nest /* Be careful */  // comment ends on this line...  */ // ...not this one! -  // Constants: #define <keyword> +// Constants: #define <keyword>  #define DAYS_IN_YEAR 365 -  // Enumeration constants are also ways to declare constants. -  enum days {SUN = 1, MON, TUE, WED, THU, FRI, SAT}; +// Enumeration constants are also ways to declare constants. +// All statements must end with a semicolon +enum days {SUN = 1, MON, TUE, WED, THU, FRI, SAT};  // MON gets 2 automatically, TUE gets 3, etc. +  // Import headers with #include  #include <stdlib.h>  #include <stdio.h> @@ -57,7 +59,6 @@ int main() {    // print output using printf, for "print formatted"    // %d is an integer, \n is a newline    printf("%d\n", 0); // => Prints 0 -  // All statements must end with a semicolon    ///////////////////////////////////////    // Types @@ -385,7 +386,8 @@ int main() {    // or when it's the argument of the `sizeof` or `alignof` operator:    int arraythethird[10];    int *ptr = arraythethird; // equivalent with int *ptr = &arr[0]; -  printf("%zu, %zu\n", sizeof arraythethird, sizeof ptr); // probably prints "40, 4" or "40, 8" +  printf("%zu, %zu\n", sizeof arraythethird, sizeof ptr); +  // probably prints "40, 4" or "40, 8"    // Pointers are incremented and decremented based on their type @@ -476,7 +478,7 @@ void testFunc() {  }  //make external variables private to source file with static: -static int j = 0; //other files using testFunc() cannot access variable i +static int j = 0; //other files using testFunc2() cannot access variable j  void testFunc2() {    extern int j;  } | 
