Programming Errors in C Language
Errors in C programming language are illegal operations or faults performed by the user which makes behavior of the program abnormal working of the program logic. Programming errors are identified during the time of compilation or execution. Some errors prevent the program from compiled or executed. Thus, the errors must be removed from the program for the successful execution of the program.
Types of Errors
There are mainly five types of errors exist in C programming:
- Syntax Error - Errors occur when programmer violate the rules of writing C language syntax are known as "Syntax errors". The compiler error must be fixed before the compilation of code. All these errors are identified by the compiler, thus these types of errors are called 'compile-time errors'.
Missing Parenthesis, printing the value of variable without declaration and missing semicolon are some of frequent syntax errors.
- Run-time Error - array, pointer, structure, unionSometimes errors occur during the program execution after successful compilation are known as run-time errors. The division by zero, out of bounds index of array or string etc. are some run-time errors which errors are very hard to find at the compile time.
- Linker Error - Linker errors occured when the executable file of the program is not generated and these can be happened either due to the wrong function prototyping or usage of the wrong header file.
- Logical Error - The logical error is a bug in a program that leads to an undesired output, but not to terminate abnormally or crash of program. These errors solely depend on the logical thinking of programmer. Many different types of programming mistakes can cause logic errors. A logic error is also known as a logical error and these are not always easy to recognize immediately.
- Semantic Error - Semantic errors occur when the statements written in the program are not meaningful or not understandable format to the C compiler.
a+b=c; // semantic error
int b = "Hello";
ADVERTISEMENT