Đang chuẩn bị liên kết để tải về tài liệu:
Module 7 More Data Types and Operators

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

A variable declared with the const modifier cannot have its value changed during the execution of your program. Thus, a const “variable” isn’t really variable! You can give a variable declared as const an initial value, however. For example, const int max_users = 9; creates an int variable called max_users that contains the value 9. This variable can be used in expressions like any other variable, but its value cannot be modified by your program. | Module 7 More Data Types and Operators Table of Contents CRITICAL SKILL 7.1 The const and volatile Qualifiers.2 CRITICAL SKILL 7.2 extern.5 CRITICAL SKILL 7.3 static Variables.6 CRITICAL SKILL 7.4 register Variables.10 CRITICAL SKILL 7.5 Enumerations.12 CRITICAL SKILL 7.6 typedef.16 CRITICAL SKILL 7.8 The Shift Operators.22 CRITICAL SKILL 7.9 The Operator.29 CRITICAL SKILL 7.10 The Comma Operator.31 CRITICAL SKILL 7.11 Compound Assignment.33 CRITICAL SKILL 7.12 Using sizeof.33 This module returns to the topics of data types and operators. In addition to the data types that you have been using so far C supports several others. Some of these consist of modifiers added to the types you already know about. Other data types include enumerations and typedefs. C also provides several additional operators that greatly expand the range of programming tasks to which C can be applied. These operators include the bitwise shift and sizeof operators. 1 C A Beginner s Guide by Herbert Schildt CRITICAL SKILL 7.1 The const and volatile Qualifiers C has two type qualifiers that affect the ways in which variables can be accessed or modified. These modifiers are const and volatile. Formally called the cv-qualifiers they precede the base type when a variable is declared. const A variable declared with the const modifier cannot have its value changed during the execution of your program. Thus a const variable isn t really variable You can give a variable declared as const an initial value however. For example const int max_users 9 creates an int variable called max_users that contains the value 9. This variable can be used in expressions like any other variable but its value cannot be modified by your program. A common use of const is to create a named constant. Often programs require the same value for many different purposes. For example a program might have several different arrays that are all the same size. In this case you can specify the size of the arrays using a const variable.