Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the scope and life cycle of variables in C language?

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about the scope and life cycle of variables in C. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

Scope and life cycle scope of variables

Scope, programming concept: Generally speaking, a name used in a piece of code is not always available, and the scope of the code that limits the availability of the name is the scope of the name.

The scope of a local variable is the local scope in which the variable is located.

The scope of global variables is the entire project.

life cycle

The life cycle of a variable refers to the time period between the creation of the variable and the destruction of the variable

The life cycle of a local variable is: the in-scope life cycle begins and the out-of-scope life cycle ends.

The life cycle of a global variable is: the life cycle of the entire program.

constant literal constant

const modified constant variable

#define Defined identifier constants

enumeration constant

String Initial String

"Hello C Travels.\ n"

This string of characters enclosed in double quotes is called a String literal, or simply a string. (Use character arrays to store strings)

Note: The end of a string is an escape character of\0. \0 is an end flag when calculating string length and does not count as string content.

library function

escape character

written examination questions

escape character list

\? Used when writing consecutive question marks to prevent them from being parsed into three-letter words\'used to represent character constants'\"used to represent double quotes inside a string\\used to represent a backslash to prevent it from being interpreted as an escape sequence character.\ a warning character, beep\b backspace\n newline\t horizontal tab\v vertical tab\dddddd indicates 1 to 3 octal digits. For example: \130 X\xdddd represents 2 hexadecimal digits. For example: 0 Comments

Unneeded code in the code can be deleted directly or commented out

Some of the code is difficult to understand, you can add a comment text

annotation style

C-style comments/* xxxx */

Defect: Cannot nest comments

C++ style comments//xxxxxx

You can comment on one line or more.

Thank you for reading! About "what is the scope and life cycle of variables in C language" this article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report