The static keyword in C is used to control the visibility and lifetime of variables and functions. It can be applied to both variables and functions.
• Syntax error
• Run-time error
• Linker error
• Logical error
• Semantic error
Definition: Syntax errors occur when the code does not follow the grammatical rules of the C language. These errors are usually detected by the compiler during the compilation process.
• Missing semicolon
• Mismatched parentheses or braces
• Incorrectly spelled keywords
Definition: Run-time errors occur during the execution of the program. These errors are not detected during compilation but cause the program to behave unexpectedly or crash when running.
• Division by zero
• Invalid memory access (e.g., accessing an array out of bounds)
• File operations on a non-existent file
Definition: Linker errors occur when the compiler tries to link various code files or libraries together. These errors typically arise when there are unresolved references or missing functions.
• Undefined functions
• Missing library files or object files
Definition: Logical errors occur when the program compiles and runs without crashing, but it produces incorrect results due to a flaw in the logic of the code. These errors are often the most challenging to identify and fix.
• Incorrect calculations
• Flawed algorithms
• Misused control structures
Definition: Semantic errors occur when the code is syntactically correct but does not do what the programmer intends. These errors can be subtle and are usually identified through testing and logical analysis.
• Using incorrect variables
• Misunderstanding the function's purpose or parameters