logo rip
RIP Tutorial
  • Tags
  • Topics
  • Examples
  • eBooks
Download C Language (PDF)

C Language

  • Getting started with C Language
  • Best C Programming Courses
  • Awesome Book
  • Awesome Community
  • Awesome Tutorial
  • Awesome YouTube
  • — character classification & conversion
  • Aliasing and effective type
  • Arrays
  • Assertion
  • Atomics
  • Bit-fields
  • Boolean
  • Command-line arguments
  • Comments
  • Common C programming idioms and developer practices
  • Common pitfalls
    • Adding a semicolon to a #define
    • Checking logical expression against 'true'
    • Comparing floating point numbers
    • Copying too much
    • Doing extra scaling in pointer arithmetic
    • Floating point literals are of type double by default
    • Forgetting to allocate one extra byte for \0
    • Forgetting to copy the return value of realloc into a temporary
    • Forgetting to free memory (memory leaks)
    • Ignoring return values of library functions
    • Incautious use of semicolons
    • Macros are simple string replacements
    • Mistakenly writing = instead of == when comparing
    • Misunderstanding array decay
    • Mixing signed and unsigned integers in arithmetic operations
    • Multi-line comments cannot be nested
    • Newline character is not consumed in typical scanf() call
    • Overstepping array boundaries
    • Passing unadjacent arrays to functions expecting "real" multidimensional arrays
    • Recursive function — missing out the base condition
    • Undefined reference errors when linking
    • Using character constants instead of string literals, and vice versa
  • Compilation
  • Compound Literals
  • Constraints
  • Create and include header files
  • Data Types
  • Declaration vs Definition
  • Declarations
  • Enumerations
  • Error handling
  • Files and I/O streams
  • Formatted Input/Output
  • Function Parameters
  • Function Pointers
  • Generic selection
  • Identifier Scope
  • Implementation-defined behaviour
  • Implicit and Explicit Conversions
  • Initialization
  • Inline assembly
  • Inlining
  • Interprocess Communication (IPC)
  • Iteration Statements/Loops: for, while, do-while
  • Jump Statements
  • Linked lists
  • Literals for numbers, characters and strings
  • Memory management
  • Multi-Character Character Sequence
  • Multithreading
  • Operators
  • Pass 2D-arrays to functions
  • Pointers
  • Preprocessor and Macros
  • Random Number Generation
  • Selection Statements
  • Sequence points
  • Side Effects
  • Signal handling
  • Standard Math
  • Storage Classes
  • Strings
  • Structs
  • Structure Padding and Packing
  • Testing frameworks
  • Threads (native)
  • Type Qualifiers
  • Typedef
  • Undefined behavior
  • Unions
  • Valgrind
  • Variable arguments
  • X-macros


C Language

  • Getting started with C Language
  • Best C Programming Courses
  • Awesome Book
  • Awesome Community
  • Awesome Tutorial
  • Awesome YouTube
  • — character classification & conversion
  • Aliasing and effective type
  • Arrays
  • Assertion
  • Atomics
  • Bit-fields
  • Boolean
  • Command-line arguments
  • Comments
  • Common C programming idioms and developer practices
  • Common pitfalls
    • Adding a semicolon to a #define
    • Checking logical expression against 'true'
    • Comparing floating point numbers
    • Copying too much
    • Doing extra scaling in pointer arithmetic
    • Floating point literals are of type double by default
    • Forgetting to allocate one extra byte for \0
    • Forgetting to copy the return value of realloc into a temporary
    • Forgetting to free memory (memory leaks)
    • Ignoring return values of library functions
    • Incautious use of semicolons
    • Macros are simple string replacements
    • Mistakenly writing = instead of == when comparing
    • Misunderstanding array decay
    • Mixing signed and unsigned integers in arithmetic operations
    • Multi-line comments cannot be nested
    • Newline character is not consumed in typical scanf() call
    • Overstepping array boundaries
    • Passing unadjacent arrays to functions expecting "real" multidimensional arrays
    • Recursive function — missing out the base condition
    • Undefined reference errors when linking
    • Using character constants instead of string literals, and vice versa
  • Compilation
  • Compound Literals
  • Constraints
  • Create and include header files
  • Data Types
  • Declaration vs Definition
  • Declarations
  • Enumerations
  • Error handling
  • Files and I/O streams
  • Formatted Input/Output
  • Function Parameters
  • Function Pointers
  • Generic selection
  • Identifier Scope
  • Implementation-defined behaviour
  • Implicit and Explicit Conversions
  • Initialization
  • Inline assembly
  • Inlining
  • Interprocess Communication (IPC)
  • Iteration Statements/Loops: for, while, do-while
  • Jump Statements
  • Linked lists
  • Literals for numbers, characters and strings
  • Memory management
  • Multi-Character Character Sequence
  • Multithreading
  • Operators
  • Pass 2D-arrays to functions
  • Pointers
  • Preprocessor and Macros
  • Random Number Generation
  • Selection Statements
  • Sequence points
  • Side Effects
  • Signal handling
  • Standard Math
  • Storage Classes
  • Strings
  • Structs
  • Structure Padding and Packing
  • Testing frameworks
  • Threads (native)
  • Type Qualifiers
  • Typedef
  • Undefined behavior
  • Unions
  • Valgrind
  • Variable arguments
  • X-macros

C Language Common pitfalls


Introduction

This section discusses some of the common mistakes that a C programmer should be aware of and should avoid making. For more on some unexpected problems and their causes, please see Undefined behavior

Common pitfalls Related Examples

  • Adding a semicolon to a #define
  • Checking logical expression against 'true'
  • Comparing floating point numbers
  • Copying too much
  • Doing extra scaling in pointer arithmetic
  • Floating point literals are of type double by default
  • Forgetting to allocate one extra byte for \0
  • Forgetting to copy the return value of realloc into a temporary
  • Forgetting to free memory (memory leaks)
  • Ignoring return values of library functions
  • Incautious use of semicolons
  • Macros are simple string replacements
  • Mistakenly writing = instead of == when comparing
  • Misunderstanding array decay
  • Mixing signed and unsigned integers in arithmetic operations
  • Multi-line comments cannot be nested
  • Newline character is not consumed in typical scanf() call
  • Overstepping array boundaries
  • Passing unadjacent arrays to functions expecting "real" multidimensional arrays
  • Recursive function — missing out the base condition
  • Undefined reference errors when linking
  • Using character constants instead of string literals, and vice versa



pdf PDF - Download C Language for free


Previous Next






This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0
This website is not affiliated with Stack Overflow

logo rip
SUPPORT & PARTNERS
  • Advertise with us
  • Contact us
  • Privacy Policy
STAY CONNECTED

Get monthly updates about new articles, cheatsheets, and tricks.