mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
fixed whitespaces
removed whitespaces all over document
This commit is contained in:
parent
5ad208e385
commit
bb74c468c2
@ -8,6 +8,7 @@ contributors:
|
|||||||
- ["Marco Scannadinari", "https://marcoms.github.io"]
|
- ["Marco Scannadinari", "https://marcoms.github.io"]
|
||||||
- ["Zachary Ferguson", "https://github.io/zfergus2"]
|
- ["Zachary Ferguson", "https://github.io/zfergus2"]
|
||||||
- ["himanshu", "https://github.com/himanshu81494"]
|
- ["himanshu", "https://github.com/himanshu81494"]
|
||||||
|
- ["Divay Prakash", "https://github.com/divayprakash"]
|
||||||
---
|
---
|
||||||
|
|
||||||
Ah, C. Still **the** language of modern high-performance computing.
|
Ah, C. Still **the** language of modern high-performance computing.
|
||||||
@ -36,7 +37,6 @@ Multi-line comments don't nest /* Be careful */ // comment ends on this line...
|
|||||||
enum days {SUN = 1, MON, TUE, WED, THU, FRI, SAT};
|
enum days {SUN = 1, MON, TUE, WED, THU, FRI, SAT};
|
||||||
// MON gets 2 automatically, TUE gets 3, etc.
|
// MON gets 2 automatically, TUE gets 3, etc.
|
||||||
|
|
||||||
|
|
||||||
// Import headers with #include
|
// Import headers with #include
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -114,7 +114,6 @@ int main (int argc, char** argv)
|
|||||||
// sizeof(obj) yields the size of the expression (variable, literal, etc.).
|
// sizeof(obj) yields the size of the expression (variable, literal, etc.).
|
||||||
printf("%zu\n", sizeof(int)); // => 4 (on most machines with 4-byte words)
|
printf("%zu\n", sizeof(int)); // => 4 (on most machines with 4-byte words)
|
||||||
|
|
||||||
|
|
||||||
// If the argument of the `sizeof` operator is an expression, then its argument
|
// If the argument of the `sizeof` operator is an expression, then its argument
|
||||||
// is not evaluated (except VLAs (see below)).
|
// is not evaluated (except VLAs (see below)).
|
||||||
// The value it yields in this case is a compile-time constant.
|
// The value it yields in this case is a compile-time constant.
|
||||||
@ -130,7 +129,6 @@ int main (int argc, char** argv)
|
|||||||
int my_int_array[20]; // This array occupies 4 * 20 = 80 bytes
|
int my_int_array[20]; // This array occupies 4 * 20 = 80 bytes
|
||||||
// (assuming 4-byte words)
|
// (assuming 4-byte words)
|
||||||
|
|
||||||
|
|
||||||
// You can initialize an array to 0 thusly:
|
// You can initialize an array to 0 thusly:
|
||||||
char my_array[20] = {0};
|
char my_array[20] = {0};
|
||||||
|
|
||||||
@ -347,7 +345,6 @@ int main (int argc, char** argv)
|
|||||||
this will print out "Error occured at i = 52 & j = 99."
|
this will print out "Error occured at i = 52 & j = 99."
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// Typecasting
|
// Typecasting
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
@ -386,7 +383,6 @@ int main (int argc, char** argv)
|
|||||||
// (%p formats an object pointer of type void *)
|
// (%p formats an object pointer of type void *)
|
||||||
// => Prints some address in memory;
|
// => Prints some address in memory;
|
||||||
|
|
||||||
|
|
||||||
// Pointers start with * in their declaration
|
// Pointers start with * in their declaration
|
||||||
int *px, not_a_pointer; // px is a pointer to an int
|
int *px, not_a_pointer; // px is a pointer to an int
|
||||||
px = &x; // Stores the address of x in px
|
px = &x; // Stores the address of x in px
|
||||||
@ -432,7 +428,6 @@ int main (int argc, char** argv)
|
|||||||
printf("%zu, %zu\n", sizeof arraythethird, sizeof ptr);
|
printf("%zu, %zu\n", sizeof arraythethird, sizeof ptr);
|
||||||
// probably prints "40, 4" or "40, 8"
|
// probably prints "40, 4" or "40, 8"
|
||||||
|
|
||||||
|
|
||||||
// Pointers are incremented and decremented based on their type
|
// Pointers are incremented and decremented based on their type
|
||||||
// (this is called pointer arithmetic)
|
// (this is called pointer arithmetic)
|
||||||
printf("%d\n", *(x_ptr + 1)); // => Prints 19
|
printf("%d\n", *(x_ptr + 1)); // => Prints 19
|
||||||
@ -578,8 +573,6 @@ void testFunc2() {
|
|||||||
}
|
}
|
||||||
//**You may also declare functions as static to make them private**
|
//**You may also declare functions as static to make them private**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// User-defined types and structs
|
// User-defined types and structs
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
@ -696,6 +689,7 @@ typedef void (*my_fnp_type)(char *);
|
|||||||
"%o"; // octal
|
"%o"; // octal
|
||||||
"%%"; // prints %
|
"%%"; // prints %
|
||||||
*/
|
*/
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// Order of Evaluation
|
// Order of Evaluation
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
@ -786,4 +780,4 @@ Readable code is better than clever code and fast code. For a good, sane coding
|
|||||||
|
|
||||||
Other than that, Google is your friend.
|
Other than that, Google is your friend.
|
||||||
|
|
||||||
[1] http://stackoverflow.com/questions/119123/why-isnt-sizeof-for-a-struct-equal-to-the-sum-of-sizeof-of-each-member
|
[1] http://stackoverflow.com/questions/119123/why-isnt-sizeof-for-a-struct-equal-to-the-sum-of-sizeof-of-each-member
|
Loading…
Reference in New Issue
Block a user