Home Tutorials C Tutorial Common Mistakes
Common Mistakes

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) inside if conditions.
  • Scanner Slip-ups: Forgetting the & (Address-of operator) in scanf() for numeric variables.

🧠 Arrays & Memory

  • Index Out of Bounds: Trying to access arr[5] in an array that only goes up to index 4.
  • 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 \0 null 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 with fclose(), 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 »