In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the rules of constant definition in c language". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
C language constant definition rules
The definition of constant: a constant is a quantity whose value cannot be changed while the program is running.
Constants in C language can be divided into direct constants and symbolic constants.
Direct constant refers to a form expressed directly by specific data, which can be divided into integer constant, real constant, character constant and string constant.
Symbolic constants refer to constants defined by C language identifiers.
Integer constants are integer constants, decimal, octal and hexadecimal numbers. For example, 10,012, 0x0A
Real constants are also called floating-point constants. Such as: 3.14, 1.2E-4
Character constants must be enclosed in single quotation marks. Such as:'M','\ n'
String constants are enclosed in double quotes. For example, "abc", "a"
Symbolic constants can be represented by macro definitions or by const keywords. For example: # define PI 3.14 const float PI = 3.14
Expansion of knowledge points:
In C, there are two simple ways to define constants:
1. Use # define preprocessor
two。 Use the const keyword
Const defines a variable, not a constant, but the value of this variable is not allowed to change is a constant! With a type. There is type checking at compile time.
Define defines constants without types and only makes simple character substitutions. It works during precompilation, and there is no type checking.
This is the end of the content of "what are the rules of constant definition in C language". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.