当前位置:网站首页>C expert programming
C expert programming
2022-08-01 21:21:00 【weixin_Guest time】
1. Demonstrate the coding skills used by excellent C programmers;
2. Detailed explanation and in-depth analysis of C's history, language features, declarations, arrays, pointers, links, runtime, memory, and how to further study C++.
3. Help C programmers with certain experience become experts in C programming; help programmers with deep knowledge of C language to understand and learn C++ from the height of C.
Programming philosophy: Anyone can enjoy programming.
Programming should be a wonderful, dynamic, and challenging activity, and a book about programming should spark a spark of passion from time to time.
Applies to ANSI standard C language on PC and UNIX systems. It describes the features in C language related to the complex hardware structure of UNIX platform (such as virtual memory, etc.)A comprehensive introduction to the impact of the C language.
Many topics that confuse C programmers:
What does*typedef struct bar{ int bar; }bar really mean?
Analysis:
The first bar is the structure tag, the second bar is the member variable name in the structure, and the third bar is the structure type.
#include
typedef struct bar {
int bar;
int z;
}bar;
/*The first bar is a structure tag name
*The second bar is a variable name of bar of type int in the structure
*The third bar is a structure type name
*struct bar struct type
*struct bar bar The first bar is a structure label, the second bar is an object name
*bar.bar The first bar is an object name, and the second bar objectmember variable of name
*/
int main() {
//error
/*typedef struct bar bac; //not allowed!
bac.bar = 5;*/
bar bar;
bar.bar = 3;
struct bar baz;
baz.bar = 4;
printf("sizeof(bar) = %d,sizeof(struct bar) = %d\nsizeof(bar.bar) =%d,sizeof(baz.bar) = %d\n",
sizeof(bar), sizeof(struct bar), sizeof(bar.bar), sizeof(baz.bar));
printf("bar.bar = %d, baz.bar = %d\n", bar.bar, baz.bar);
Return 0;
}
/* output:

*/
*How do I pass some multidimensional arrays of different sizes into the same function?
Analysis:
Multidimensional arrays of different sizes can be passed into the same function by flattening the array into a one-dimensional array.
*Why extern char *p; cannot match the char p[100]; of another file?
Analysis:
Why do people think that pointers and arrays should always be interchangeable?The answer is that a reference to an array can always be written as a reference to a pointer, and there does exist a context where pointers and arrays are defined exactly the same.Unfortunately, this is only a very common use of arrays, and this is not the case in all cases.When you extract the contents of this declaration in the form p[i], you actually get a single character.But according to the pointer method, the compiler treats it as a pointer, and interpreting ASCII characters as addresses is obviously wrong.
*What is a bus error? What is a segmentation violation?
Analysis:
A bus error is due to an unaligned memory access request, and the blocked component is the address bus.Alignment means that data items can only be stored in memory locations whose addresses are an integer multiple of the size of the data item.In fact, bus errors are almost always caused by misaligned reads or writes.Segmentation violations are generally caused by exceptions in the memory management unit (the hardware responsible for supporting virtual memory), which are usually caused by de-initializing a pointer to an uninitialized or illegal value.
What is the difference between *char *foo[] and char (*foo)[]?
Analysis:
//foo is a pointer, elements in array is a pointer points to the char
char *foo[];
//foo is a pointer, pointer points to a array of char
char(*foo)[];
边栏推荐
- JS提升:如何中断Promise的链式调用
- C专家编程 第1章 C:穿越时空的迷雾 1.4 K&R C
- Suggestions and answer 8.1 C traps and defect chapter 8
- 软考 ----- UML设计与分析(上)
- ORI-GB-NP半乳糖介导冬凌草甲素/姜黄素牛血清白蛋白纳米粒的研究制备方法
- 51.【结构体初始化的两种方法】
- 空间数据库开源路,超图+openGauss风起禹贡
- C Pitfalls and Defects Chapter 5 Library Functions 5.5 Library Function Signal
- 15 分钟带你入门 Grafana
- 函数(二)
猜你喜欢

虚拟内存与物理内存之间的关系

JS Improvement: Handwritten Publish Subscriber Model (Xiaobai)

Interview Blitz 70: What are sticky packs and half packs?How to deal with it?

R语言 线性回归的有关方法

ORI-GB-NP半乳糖介导冬凌草甲素/姜黄素牛血清白蛋白纳米粒的研究制备方法

Questions I don't know in database kernel interview(1)

Shell编程之条件语句

TP5-NPs负载噻吩类化合物TP5白蛋白纳米粒/阿魏酸钠新糖牛血清蛋白纳米粒

C专家编程 第1章 C:穿越时空的迷雾 1.4 K&R C

Internet使用的网络协议是什么
随机推荐
C pitfalls and pitfalls Chapter 8 Suggestions and answers 8.2 Answers
JS提升:手写发布订阅者模式(小白篇)
深拷贝浅拷贝
Appendix A printf, varargs and stdarg a. 2 use varargs. H to realize the variable argument list
R语言 线性回归的有关方法
HCIP---多生成树协议相关知识点
Questions I don't know in database kernel interview(1)
LeetCode每日一题(1807. Evaluate the Bracket Pairs of a String)
JSD-2204-Knife4j框架-处理响应结果-Day07
LeetCode·每日一题·1374.生成每种字符都是奇数个的字符串·模拟
C语言_typedef和结构体
对C语言结构体内存对齐的理解
C Pitfalls and Defects Chapter 7 Portability Defects 7.8 Size of Random Numbers
JVM内存结构详解
How to encapsulate the cookie/localStorage sessionStorage hook?
网红驼背矫正产品真的管用吗?如何预防驼背?医生说要这样做
Classification interface, Taobao classification details API
XSS漏洞
技术栈概览
LeetCode