当前位置:网站首页>C language learning log 1.24
C language learning log 1.24
2022-06-13 04:58:00 【Today is also a day without baldness】
typedef:
C language ⾔ Provides ⼀ One is called typedef To declare ⼀ Of existing data types New name .
⽐ Such as : typedef int Length; bring Length Become int Alias for type .
• such , Length This name can replace int It's in the place of variable definition and parameter declaration :
Length a, b, len ;
Length numbers[10] ;
Declare the name of the new type —— The new name is some kind of alias , He improved the readability of the program
typedef int Length; // Length It is equivalent to int type
typedef char* Strings[10]; // Strings yes 10 An array of strings
The type of
typedef struct node {
int data;
struct node *next;
} aNode;
or
typedef struct node aNode; // such ⽤aNode It can replace
struct node
union :
C Consortia in language , It is a structure of multiple variables that uses a memory area at the same time , The value of the region is the value of the variable with the largest length in the structure . Its usage and structure are similar
union AnElt {
int i;
char c;
} elt1, elt2; // Defined elt1,elt2 Two about structure Anelt The consortium of
elt1.i = 4; // Yes elt1 Medium i assignment
elt2.c = ’a’; // Yes elt2 Medium c assignment
elt2.i = 0xDEADBEEF;// Yes elt2 Medium i assignment , this elt2 The memory footprint in is i Occupy
TIPS: About Union , It has only one member at a time , All members share the same memory area ,union The size of is the size of its largest member .
TIP: The processing method of the small end is that the low end is in front .
边栏推荐
- 利用Javeswingjdbc基于mvc设计系统
- Embedded hardware - read schematic
- OJ problem solution summary
- Differences between string() and tostring() methods
- 自动评教脚本使用的配置
- How to handle async/await error messages gracefully
- Normal distribution (Gaussian distribution)
- Clause 34: lambda is preferred over std:: bind
- Four methods for judging JS data types and user-defined methods
- Kaggle 时间序列教程
猜你喜欢
Optocoupler working principle function electric parameter application circuit
Explain the role of key attribute in V-for
PostgreSQL Guide: Insider exploration (Chapter 7 heap tuples and index only scanning) - Notes
详解OpenCV的函数cv::add(),并附各种情况的示例代码和运行结果
Kaggle time series tutorial
Regular expressions in QT
Win8.1和Win10各自的优势
[LeetCode]-二分查找
Configuration used by automatic teaching evaluation script
How to use redis
随机推荐
Embedded hardware - read schematic
Analysis on the similarities and differences of MVC, MVP and mvvc
Section 7 - structures
OJ problem solution summary
Regular expressions in QT
约瑟夫问题
CMB written test graphical reasoning
Optocoupler working principle function electric parameter application circuit
【JS解决】leedcode 117. 填充每个节点的下一个右侧节点指针 II
Article 29: assuming that the mobile operation does not exist, is expensive, and is not used
The processing flow of thread pool depends on the core parameters
C language learning log 10.5
C language learning log 10.11
JS to realize the conversion between string and array and an interview question
PostgreSQL Guide: inside exploration (Chapter 10 basic backup and point in time recovery) - Notes
Common skills in embedded programming
Spread your wings and soar
Keil uses j-link to burn the code, and an error occurs: Flash download failed - one of the "Cortex-M3" solutions
Little C's Notepad
无限循环滚动代码阿里巴巴国际站店铺装修代码底图滚动黑色半透明显示效果自定义内容装修代码全屏显示