Programming Errors in C Language
Categories: C language
Errors are the problems or the faults that occur in the program, which makes the behavior of the program abnormal, and experienced developers can also make these faults. Programming errors are also known as the bugs or faults, and the process of removing these bugs is known as debugging.
These errors are detected either during the time of compilation or execution. Thus, the errors must be removed from the program for the successful execution of the program.
There are mainly five types of errors exist in C programming:
1. Syntax error
2. Run-time error
3. Linker error
4. Logical error
6. Semantic error
Syntax error
Syntax errors are also known as the compilation errors as they occurred at the compilation time, or we can say that the syntax errors are thrown by the compilers. These errors are mainly occurred due to the mistakes while typing or do not follow the syntax of the specified programming language. These mistakes are generally made by beginners only because they are new to the language. These errors can be easily debugged or corrected.
Run-time error
Sometimes the errors exist during the execution-time even after the successful compilation known as run-time errors. When the program is running, and it is not able to perform the operation is the main cause of the run-time error. The division by zero is the common example of the run-time error. These errors are very difficult to find, as the compiler does not point to these errors.
Linker error
Linker errors are mainly generated when the executable file of the program is not created. This can be happened either due to the wrong function prototyping or usage of the wrong header file. For example, the main.c file contains the sub() function whose declaration and definition is done in some other file such as func.c. During the compilation, the compiler finds the sub() function in func.c file, so it generates two object files, i.e., main.o and func.o. At the execution time, if the definition of sub() function is not found in the func.o file, then the linker error will be thrown. The most common linker error that occurs is that we use Main() instead of main().
Semantic error
Semantic errors are the errors that occurred when the statements are not understandable by the compiler.
The following can be the cases for the semantic error:
Use of a un-initialized variable.
int i;
i=i+2;
Type compatibility
int b = "javatpoint";
Errors in expressions
int a, b, c;
a+b = c;
Array index out of bound
int a[10];
a[10] = 34;