C Language Learning Diary 7

Source: Internet
Author: User

2.2 Constants

The amount of the program does not change during operation. is given when initializing.

2.2.1 #define

2.2.2 Const

After the const modifier variable, the variable becomes constant.

Const and pointers are combined in a total of 4 forms

const int *p; P is a pointer to an int type of data. P is pointing to a constant.

int const *P; P is a pointer to an int type of data. P is pointing to a constant.

int *const p; P is a pointer to an int type of data. P itself is a constant, and p points to a variable.

const int *const *p; P is a pointer to an int type of data. P itself is a constant, and p points to a constant.

Const-type pointers are primarily used in string pointers.

2.2.3 Enum constant enum

Enumeration constants are a substitute for macro definitions and, in some cases, are more useful than macro definitions.

Introduction of 3.6 Header files

It is primarily used to collect declarations of functions and global variables.

#ifndef __a_h__

#define __a_h__

#endif __a_h__ is used to prevent duplicate inclusion of header files.

Do not define variables in the header file. The definition of a global variable is placed in a source file, and then used in a different source file before using the extern declaration.

C Language Learning Diary 7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.