implicit declaration

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

implicit declaration
Implicit declarations are a type of declaration in C programming language that are assumed by the language, not stated explicitly. They come into play when assigning values to variables that have not been declared with the keyword “extern” prior. The assumption by the language is that the variable should be of type “int”.
When a variable is declared as an “int”, the default value that gets applied to that variable is zero. However, when an implicit declaration take place, the default value for the variable is an undefined value. This undefined value can contain any number that is not a valid integer.
In most cases, this is not a problem and the code will still run correctly. However, there are some situations where it can cause strange results. For example, if you are using a variable without declaring it first, and it has an undefined value, you may get erroneous results in a calculation you are performing.
For those reasons, it is usually not recommended to rely on implicit declarations when programming in C. Instead, it is better to declare all variables explicitly and assign default values to them when necessary.
One of the best ways to make sure you are explicitly declaring all of your variables is to use a program such as the GNU Compiler. This compiler will detect any implicit declaration and alert you of the problem. Once you have identified the problem, you can then make sure to assign default values to those variables to prevent any problems.
In conclusion, implicit declarations are a necessary part of the C programming language, but it is best to avoid them when you can. When you do use them, make sure to explicitly declare all variables and assign default values to them accordingly. Doing so will help ensure your code runs smoothly and accurately.。

相关文档
最新文档