Common Mistakes
Introduction to C
Structure of a C Program
Variables and Data Types
Input and Output
Operators in C
Decision Making
If Statement
if...else Statement
Nested if Statement
Nested if...else Statement
Switch Statement
Loops
For Loop
While Loop
Do While Loop
Loop Comparison
Arrays
Strings
Functions
Function Types
Library Functions
User-Defined Functions
Recursion Function
Pointers
Structures
File Handling
Common Mistakes
Ideas
Common Mistakes
⚠️ Common Mistakes Beginners Make
Even expert programmers started by making these mistakes. Pay close attention to these "debugging traps" to save yourself hours of frustration!
💻 Syntax & Logic
- The Missing Semicolon: Forgetting
;at the end of a statement (The #1 reason for "Expected ';' before..." errors). - Assignment vs Equality: Using
=(to set a value) instead of==(to check a value) insideifconditions. - Scanner Slip-ups: Forgetting the
&(Address-of operator) inscanf()for numeric variables.
🧠 Arrays & Memory
- Index Out of Bounds: Trying to access
arr[5]in an array that only goes up to index4. - Wild Pointers: Using a pointer variable before assigning it a valid memory address.
- String Buffer Overflow: Creating a string array that is too small to hold the text plus the
\0null character.
📂 Functions & Files
- Return Values: Forgetting to return a value from a function that isn't declared as
void. - Dangling Files: Opening a file with
fopen()but forgetting to close it withfclose(), causing data loss. - Infinite Recursion: Writing a recursive function without a clear Base Case to stop it.
💡
Skilleco Debugging Tip: If your program compiles but gives strange results, check your if statements. if(x = 5) will always be True because it assigns 5 to x! Always use if(x == 5) for comparisons.
🏋️ Test Yourself With Exercises
Take our quiz on Common Mistakes to test your knowledge.
Browse Quizzes »