C Notes for Professionals book

    Amazing collection of free programming books

    Collecting
    Free
    Amazing collection of free programming books

    The Notes for Professionals book is compiled from Stack Overflow Documentation, the content is written by the beautiful people at Stack Overflow. Text content is released under Creative Commons BY-SA. See credits at the end of this book whom contributed to the various chapters. Images may be copyright of their respective owners unless otherwise specified

    Book created for educational purposes and is not affiliated with group(s), company(s) nor Stack Overflow. All trademarks belong to their respective company owners

    https://goalkicker.com/

    Content

    1-1Content list
    1-2About
    1-3Chapter 1: Getting started with C Language
    1-4Section 1.1: Hello World
    1-5Section 1.2: Original "Hello, World!" in K&R C
    1-6Chapter 2: Comments
    1-7Section 2.1: Commenting using the preprocessor
    1-8Section 2.2: /* */ delimited comments
    1-9Section 2.3: // delimited comments
    1-10Section 2.4: Possible pitfall due to trigraphs
    1-11Chapter 3: Data Types
    1-12Section 3.1: Interpreting Declarations
    1-13Section 3.2: Fixed Width Integer Types (since C99)
    1-14Section 3.3: Integer types and constants
    1-15Section 3.4: Floating Point Constants
    1-16Section 3.5: String Literals
    1-17Chapter 4: Operators
    1-18Section 4.1: Relational Operators
    1-19Section 4.2: Conditional Operator/Ternary Operator
    1-20Section 4.3: Bitwise Operators
    1-21Section 4.4: Short circuit behavior of logical operators
    1-22Section 4.5: Comma Operator
    1-23Section 4.6: Arithmetic Operators
    1-24Section 4.7: Access Operators
    1-25Section 4.8: sizeof Operator
    1-26Section 4.9: Cast Operator
    1-27Section 4.10: Function Call Operator
    1-28Section 4.11: Increment / Decrement
    1-29Section 4.12: Assignment Operators
    1-30Section 4.13: Logical Operators
    1-31Section 4.14: Pointer Arithmetic
    1-32Section 4.15: _Alignof
    1-33Chapter 5: Boolean
    1-34Section 5.1: Using stdbool.h
    1-35Section 5.2: Using #define
    1-36Section 5.3: Using the Intrinsic (built-in) Type _Bool
    1-37Section 5.4: Integers and pointers in Boolean expressions
    1-38Section 5.5: Defining a bool type using typedef
    1-39Chapter 6: Strings
    1-40Section 6.1: Tokenisation: strtok(), strtok_r() and strtok_s()
    1-41Section 6.2: String literals
    1-42Section 6.3: Calculate the Length: strlen()
    1-43Section 6.4: Basic introduction to strings
    1-44Section 6.5: Copying strings
    1-45Section 6.6: Iterating Over the Characters in a String
    1-46Section 6.7: Creating Arrays of Strings
    1-47Section 6.8: Convert Strings to Number: atoi(), atof() (dangerous, don't use them)
    1-48Section 6.9: string formatted data read/write
    1-49Section 6.10: Find first/last occurrence of a specific character: strchr(), strrchr()
    1-50Section 6.11: Copy and Concatenation: strcpy(), strcat()
    1-51Section 6.12: Comparsion: strcmp(), strncmp(), strcasecmp(), strncasecmp()
    1-52Section 6.13: Safely convert Strings to Number: strtoX functions
    1-53Section 6.14: strspn and strcspn
    1-54Chapter 7: Literals for numbers, characters and strings
    1-55Section 7.1: Floating point literals
    1-56Section 7.2: String literals
    1-57Section 7.3: Character literals
    1-58Section 7.4: Integer literals
    1-59Chapter 8: Compound Literals
    1-60Section 8.1: Definition/Initialisation of Compound Literals
    1-61Chapter 9: Bit-fields
    1-62Section 9.1: Bit-fields
    1-63Section 9.2: Using bit-fields as small integers
    1-64Section 9.3: Bit-field alignment
    1-65Section 9.4: Don'ts for bit-fields
    1-66Section 9.5: When are bit-fields useful?
    1-67Chapter 10: Arrays
    1-68Section 10.1: Declaring and initializing an array
    1-69Section 10.2: Iterating through an array eciently and row-major order
    1-70Section 10.3: Array length
    1-71Section 10.4: Passing multidimensional arrays to a function
    1-72Section 10.5: Multi-dimensional arrays
    1-73Section 10.6: Define array and access array element
    1-74Section 10.7: Clearing array contents (zeroing)
    1-75Section 10.8: Setting values in arrays
    1-76Section 10.9: Allocate and zero-initialize an array with user defined size
    1-77Section 10.10: Iterating through an array using pointers
    1-78Chapter 11: Linked lists
    1-79Section 11.1: A doubly linked list
    1-80Section 11.2: Reversing a linked list
    1-81Section 11.3: Inserting a node at the nth position
    1-82Section 11.4: Inserting a node at the beginning of a singly linked list
    1-83Chapter 12: Enumerations
    1-84Section 12.1: Simple Enumeration
    1-85Section 12.2: enumeration constant without typename
    1-86Section 12.3: Enumeration with duplicate value
    1-87Section 12.4: Typedef enum
    1-88Chapter 13: Structs
    1-89Section 13.1: Flexible Array Members
    1-90Section 13.2: Typedef Structs
    1-91Section 13.3: Pointers to structs
    1-92Section 13.4: Passing structs to functions
    1-93Section 13.5: Object-based programming using structs
    1-94Section 13.6: Simple data structures
    1-95Chapter 14: Standard Math
    1-96Section 14.1: Power functions - pow(), powf(), powl()
    1-97Section 14.2: Double precision floating-point remainder: fmod()
    1-98Section 14.3: Single precision and long double precision floating-point remainder: fmodf(), fmodl()
    1-99Chapter 15: Iteration Statements/Loops: for, while, do-while
    1-100Section 15.1: For loop
    1-101Section 15.2: Loop Unrolling and Du's Device
    1-102Section 15.3: While loop
    1-103Section 15.4: Do-While loop
    1-104Section 15.5: Structure and flow of control in a for loop
    1-105Section 15.6: Infinite Loops
    1-106Chapter 16: Selection Statements
    1-107Section 16.1: if () Statements
    1-108Section 16.2: Nested if()...else VS if()..else Ladder
    1-109Section 16.3: switch () Statements
    1-110Section 16.4: if () ... else statements and syntax
    1-111Section 16.5: if()...else Ladder Chaining two or more if () ... else statements
    1-112Chapter 17: Initialization
    1-113Section 17.1: Initialization of Variables in C
    1-114Section 17.2: Using designated initializers
    1-115Section 17.3: Initializing structures and arrays of structures
    1-116Chapter 18: Declaration vs Definition
    1-117Section 18.1: Understanding Declaration and Definition
    1-118Chapter 19: Command-line arguments
    1-119Section 19.1: Print the arguments to a program and convert to integer values
    1-120Section 19.2: Printing the command line arguments
    1-121Section 19.3: Using GNU getopt tools
    1-122Chapter 20: Files and I/O streams
    1-123Section 20.1: Open and write to file
    1-124Section 20.2: Run process
    1-125Section 20.3: fprintf
    1-126Section 20.4: Get lines from a file using getline()
    1-127Section 20.5: fscanf()
    1-128Section 20.6: Read lines from a file
    1-129Section 20.7: Open and write to a binary file
    1-130Chapter 21: Formatted Input/Output
    1-131Section 21.1: Conversion Specifiers for printing
    1-132Section 21.2: The printf() Function
    1-133Section 21.3: Printing format flags
    1-134Section 21.4: Printing the Value of a Pointer to an Object
    1-135Section 21.5: Printing the Dierence of the Values of two Pointers to an Object
    1-136Section 21.6: Length modifiers
    1-137Chapter 22: Pointers
    1-138Section 22.1: Introduction
    1-139Section 22.2: Common errors
    1-140Section 22.3: Dereferencing a Pointer
    1-141Section 22.4: Dereferencing a Pointer to a struct
    1-142Section 22.5: Const Pointers
    1-143Section 22.6: Function pointers
    1-144Section 22.7: Polymorphic behaviour with void pointers
    1-145Section 22.8: Address-of Operator ( & )
    1-146Section 22.9: Initializing Pointers
    1-147Section 22.10: Pointer to Pointer
    1-148Section 22.11: void* pointers as arguments and return values to standard functions
    1-149Section 22.12: Same Asterisk, Dierent Meanings
    1-150Chapter 23: Sequence points
    1-151Section 23.1: Unsequenced expressions
    1-152Section 23.2: Sequenced expressions
    1-153Section 23.3: Indeterminately sequenced expressions
    1-154Chapter 24: Function Pointers
    1-155Section 24.1: Introduction
    1-156Section 24.2: Returning Function Pointers from a Function
    1-157Section 24.3: Best Practices
    1-158Section 24.4: Assigning a Function Pointer
    1-159Section 24.5: Mnemonic for writing function pointers
    1-160Section 24.6: Basics
    1-161Chapter 25: Function Parameters
    1-162Section 25.1: Parameters are passed by value
    1-163Section 25.2: Passing in Arrays to Functions
    1-164Section 25.3: Order of function parameter execution
    1-165Section 25.4: Using pointer parameters to return multiple values
    1-166Section 25.5: Example of function returning struct containing values with error codes
    1-167Chapter 26: Pass 2D-arrays to functions
    1-168Section 26.1: Pass a 2D-array to a function
    1-169Section 26.2: Using flat arrays as 2D arrays
    1-170Chapter 27: Error handling
    1-171Section 27.1: errno
    1-172Section 27.2: strerror
    1-173Section 27.3: perror
    1-174Chapter 28: Undefined behavior
    1-175Section 28.1: Dereferencing a pointer to variable beyond its lifetime
    1-176Section 28.2: Copying overlapping memory
    1-177Section 28.3: Signed integer overflow
    1-178Section 28.4: Use of an uninitialized variable
    1-179Section 28.5: Data race
    1-180Section 28.6: Read value of pointer that was freed
    1-181Section 28.7: Using incorrect format specifier in printf
    1-182Section 28.8: Modify string literal
    1-183Section 28.9: Passing a null pointer to printf %s conversion
    1-184Section 28.10: Modifying any object more than once between two sequence points
    1-185Section 28.11: Freeing memory twice
    1-186Section 28.12: Bit shifting using negative counts or beyond the width of the type
    1-187Section 28.13: Returning from a function that's declared with `_Noreturn` or `noreturn` function specifier
    1-188Section 28.14: Accessing memory beyond allocated chunk
    1-189Section 28.15: Modifying a const variable using a pointer
    1-190Section 28.16: Reading an uninitialized object that is not backed by memory
    1-191Section 28.17: Addition or subtraction of pointer not properly bounded
    1-192Section 28.18: Dereferencing a null pointer
    1-193Section 28.19: Using ush on an input stream
    1-194Section 28.20: Inconsistent linkage of identifiers
    1-195Section 28.21: Missing return statement in value returning function
    1-196Section 28.22: Division by zero
    1-197Section 28.23: Conversion between pointer types produces incorrectly aligned result
    1-198Section 28.24: Modifying the string returned by getenv, strerror, and setlocale functions
    1-199Chapter 29: Random Number Generation
    1-200Section 29.1: Basic Random Number Generation
    1-201Section 29.2: Permuted Congruential Generator
    1-202Section 29.3: Xorshift Generation
    1-203Section 29.4: Restrict generation to a given range
    1-204Chapter 30: Preprocessor and Macros
    1-205Section 30.1: Header Include Guards
    1-206Section 30.2: #if 0 to block out code sections
    1-207Section 30.3: Function-like macros
    1-208Section 30.4: Source file inclusion
    1-209Section 30.5: Conditional inclusion and conditional function signature modification
    1-210Section 30.6: __cplusplus for using C externals in C++ code compiled with C++ - name mangling
    1-211Section 30.7: Token pasting
    1-212Section 30.8: Predefined Macros
    1-213Section 30.9: Variadic arguments macro
    1-214Section 30.10: Macro Replacement
    1-215Section 30.11: Error directive
    1-216Section 30.12: FOREACH implementation
    1-217Chapter 31: Signal handling
    1-218Section 31.1: Signal Handling with “signal()”
    1-219Chapter 32: Variable arguments
    1-220Section 32.1: Using an explicit count argument to determine the length of the va_list
    1-221Section 32.2: Using terminator values to determine the end of va_list
    1-222Section 32.3: Implementing functions with a `printf()`-like interface
    1-223Section 32.4: Using a format string
    1-224Chapter 33: Assertion
    1-225Section 33.1: Simple Assertion
    1-226Section 33.2: Static Assertion
    1-227Section 33.3: Assert Error Messages
    1-228Section 33.4: Assertion of Unreachable Code
    1-229Section 33.5: Precondition and Postcondition
    1-230Chapter 34: Generic selection
    1-231Section 34.1: Check whether a variable is of a certain qualified type
    1-232Section 34.2: Generic selection based on multiple arguments
    1-233Section 34.3: Type-generic printing macro
    1-234Chapter 35: X-macros
    1-235Section 35.1: Trivial use of X-macros for printfs
    1-236Section 35.2: Extension: Give the X macro as an argument
    1-237Section 35.3: Enum Value and Identifier
    1-238Section 35.4: Code generation
    1-239Chapter 36: Aliasing and eective type
    1-240Section 36.1: Eective type
    1-241Section 36.2: restrict qualification
    1-242Section 36.3: Changing bytes
    1-243Section 36.4: Character types cannot be accessed through non-character types
    1-244Section 36.5: Violating the strict aliasing rules
    1-245Chapter 37: Compilation
    1-246Section 37.1: The Compiler
    1-247Section 37.2: File Types
    1-248Section 37.3: The Linker
    1-249Section 37.4: The Preprocessor
    1-250Section 37.5: The Translation Phases
    1-251Chapter 38: Inline assembly
    1-252Section 38.1: gcc Inline assembly in macros
    1-253Section 38.2: gcc Basic asm support
    1-254Section 38.3: gcc Extended asm support
    1-255Chapter 39: Identifier Scope
    1-256Section 39.1: Function Prototype Scope
    1-257Section 39.2: Block Scope
    1-258Section 39.3: File Scope
    1-259Section 39.4: Function scope
    1-260Chapter 40: Implicit and Explicit Conversions
    1-261Section 40.1: Integer Conversions in Function Calls
    1-262Section 40.2: Pointer Conversions in Function Calls
    1-263Chapter 41: Type Qualifiers
    1-264Section 41.1: Volatile variables
    1-265Section 41.2: Unmodifiable (const) variables
    1-266Chapter 42: Typedef
    1-267Section 42.1: Typedef for Structures and Unions
    1-268Section 42.2: Typedef for Function Pointers
    1-269Section 42.3: Simple Uses of Typedef
    1-270Chapter 43: Storage Classes
    1-271Section 43.1: auto
    1-272Section 43.2: register
    1-273Section 43.3: static
    1-274Section 43.4: typedef
    1-275Section 43.5: extern
    1-276Section 43.6: _Thread_local
    1-277Chapter 44: Declarations
    1-278Section 44.1: Calling a function from another C file
    1-279Section 44.2: Using a Global Variable
    1-280Section 44.3: Introduction
    1-281Section 44.4: Typedef
    1-282Section 44.5: Using Global Constants
    1-283Section 44.6: Using the right-left or spiral rule to decipher C declaration
    1-284Chapter 45: Structure Padding and Packing
    1-285Section 45.1: Packing structures
    1-286Section 45.2: Structure padding
    1-287Chapter 46: Memory management
    1-288Section 46.1: Allocating Memory
    1-289Section 46.2: Freeing Memory
    1-290Section 46.3: Reallocating Memory
    1-291Section 46.4: realloc(ptr, 0) is not equivalent to free(ptr)
    1-292Section 46.5: Multidimensional arrays of variable size
    1-293Section 46.6: alloca: allocate memory on stack
    1-294Section 46.7: User-defined memory management
    1-295Chapter 47: Implementation-defined behaviour
    1-296Section 47.1: Right shift of a negative integer
    1-297Section 47.2: Assigning an out-of-range value to an integer
    1-298Section 47.3: Allocating zero bytes
    1-299Section 47.4: Representation of signed integers
    1-300Chapter 48: Atomics
    1-301Section 48.1: atomics and operators
    1-302Chapter 49: Jump Statements
    1-303Section 49.1: Using return
    1-304Section 49.2: Using goto to jump out of nested loops
    1-305Section 49.3: Using break and continue
    1-306Chapter 50: Create and include header files
    1-307Section 50.1: Introduction
    1-308Section 50.2: Self-containment
    1-309Section 50.3: Minimality
    1-310Section 50.4: Notation and Miscellany
    1-311Section 50.5: Idempotence
    1-312Section 50.6: Include What You Use (IWYU)
    1-313Chapter 51: <ctype.h> — character classification & conversion
    1-314Section 51.1: Introduction
    1-315Section 51.2: Classifying characters read from a stream
    1-316Section 51.3: Classifying characters from a string
    1-317Chapter 52: Side Eects
    1-318Section 52.1: Pre/Post Increment/Decrement operators
    1-319Chapter 53: Multi-Character Character Sequence
    1-320Section 53.1: Trigraphs
    1-321Section 53.2: Digraphs
    1-322Chapter 54: Constraints
    1-323Section 54.1: Duplicate variable names in the same scope
    1-324Section 54.2: Unary arithmetic operators
    1-325Chapter 55: Inlining
    1-326Section 55.1: Inlining functions used in more than one source file
    1-327Chapter 56: Unions
    1-328Section 56.1: Using unions to reinterpret values
    1-329Section 56.2: Writing to one union member and reading from another
    1-330Section 56.3: Dierence between struct and union
    1-331Chapter 57: Threads (native)
    1-332Section 57.1: Inititialization by one thread
    1-333Section 57.2: Start several threads
    1-334Chapter 58: Multithreading
    1-335Section 58.1: C11 Threads simple example
    1-336Chapter 59: Interprocess Communication (IPC)
    1-337Section 59.1: Semaphores
    1-338Chapter 60: Testing frameworks
    1-339Section 60.1: Unity Test Framework
    1-340Section 60.2: CMocka
    1-341Section 60.3: CppUTest
    1-342Chapter 61: Valgrind
    1-343Section 61.1: Bytes lost -- Forgetting to free
    1-344Section 61.2: Most common errors encountered while using Valgrind
    1-345Section 61.3: Running Valgrind
    1-346Section 61.4: Adding flags
    1-347Chapter 62: Common C programming idioms and developer practices
    1-348Section 62.1: Comparing literal and variable
    1-349Section 62.2: Do not leave the parameter list of a function blank — use void
    1-350Chapter 63: Common pitfalls
    1-351Section 63.1: Mixing signed and unsigned integers in arithmetic operations
    1-352Section 63.2: Macros are simple string replacements
    1-353Section 63.3: Forgetting to copy the return value of realloc into a temporary
    1-354Section 63.4: Forgetting to allocate one extra byte for \0
    1-355Section 63.5: Misunderstanding array decay
    1-356Section 63.6: Forgetting to free memory (memory leaks)
    1-357Section 63.7: Copying too much
    1-358Section 63.8: Mistakenly writing = instead of == when comparing
    1-359Section 63.9: Newline character is not consumed in typical scanf() call
    1-360Section 63.10: Adding a semicolon to a #define
    1-361Section 63.11: Incautious use of semicolons
    1-362Section 63.12: Undefined reference errors when linking
    1-363Section 63.13: Checking logical expression against 'true'
    1-364Section 63.14: Doing extra scaling in pointer arithmetic
    1-365Section 63.15: Multi-line comments cannot be nested
    1-366Section 63.16: Ignoring return values of library functions
    1-367Section 63.17: Comparing floating point numbers
    1-368Section 63.18: Floating point literals are of type double by default
    1-369Section 63.19: Using character constants instead of string literals, and vice versa
    1-370Section 63.20: Recursive function — missing out the base condition
    1-371Section 63.21: Overstepping array boundaries
    1-372Section 63.22: Passing unadjacent arrays to functions expecting "real" multidimensional arrays
    1-373Credits
    1-374You may also like

    FAQ

    您可以透過手機、平板或是電腦登入 HiSKIO 平台,在【我的學習】>【我的書籍】頁面,選擇想看的電子書。

    Recommendations

    Reviews

    | Collecting

    Sales Plans