-
Notifications
You must be signed in to change notification settings - Fork 0
/
ErrorsInC.cpp
70 lines (52 loc) · 2.43 KB
/
ErrorsInC.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<<<<<<< HEAD
// Errors In C
=======
Errros In C
>>>>>>> 5cbaa9480fd828b374b90e2e6f60525ba8f6bcae
/* Errors are simply unavoidable when you develop a program, lets learn more about them
Learning to code can be a frustrating endeavor because you are destined to encounter many red errors along the way. What makes a programmer successful isn’t avoiding errors — no programmer can avoid them. Great programmers understand that errors are part of the process, and they know how to find the solution to each while learning something new from them. In this article, we’ll teach you how to think about errors in your code a little differently.*/
// there are many ways of classifying errrors. For example:
<<<<<<< HEAD
- Compile-time errors: Errors found by the compiler. We can further classify compile-time errors based on which language rules they violate:
- Syntax errors
- Semantic errors
=======
- Compile-time errors: Errors found by the compiler. We can further classify compile-time errors based on which language rules they violate:
- Syntax errors
- Semantic errors
>>>>>>> 5cbaa9480fd828b374b90e2e6f60525ba8f6bcae
- Link-time Error: errors found by the linker when it is trying to combine object files into an executbale program.
- Logic-errors: errors found by the programmer looking for the cause of erroneous results else end
// Compile-time errors
/* When you are writing C programs, your compiler is your first line of defense against errors. Here are the two types of compile-time errors:
Syntax errors
These errors occur when an invalid statement is written. */
<<<<<<< HEAD
`
int x = 6 // Error: missing a terminating semicolon
Int x = 6; // Error: Int is not a type
printf("Error"; // Error: missing closing parenthesis
`
=======
`
int x = 6 // Error: missing a terminating semicolon
Int x = 6; // Error: Int is not a type
printf("Error"; // Error: missing closing parenthesis
`
>>>>>>> 5cbaa9480fd828b374b90e2e6f60525ba8f6bcae
/*
Semantic Errors
These statements are syntactically valid but don't do what the programmer intends.
*/
<<<<<<< HEAD
`
a + b = c; // Error: value required as left operand of assignment
int i;
i = i + 2; // Error: use of an un-initialized variable
=======
`
a + b = c; // Error: value required as left operand of assignment
int i;
i = i + 2; // Error: use of an un-initialized variable
>>>>>>> 5cbaa9480fd828b374b90e2e6f60525ba8f6bcae
`