mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-02-17 14:24:56 +01:00
Merge pull request #2169 from divayprakash/typos-fix2
[c/en] fixed whitespaces
This commit is contained in:
commit
ac76cf11dd
@ -36,7 +36,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 +113,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 +128,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 +344,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 +382,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 +427,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 +572,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 +688,7 @@ typedef void (*my_fnp_type)(char *);
|
|||||||
"%o"; // octal
|
"%o"; // octal
|
||||||
"%%"; // prints %
|
"%%"; // prints %
|
||||||
*/
|
*/
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// Order of Evaluation
|
// Order of Evaluation
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
@ -786,4 +779,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…
x
Reference in New Issue
Block a user