当前位置:网站首页>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 Improvement: Handwritten Publish Subscriber Model (Xiaobai)
- R语言 pca主成分分析的主要方法
- 磷酸化甘露糖苷修饰白蛋白纳米粒/卵白蛋白-葡聚糖纳米凝胶的
- Taobao's API to get the list of shipping addresses
- LeetCode
- 【力扣】字符串相乘
- C Pitfalls and Defects Chapter 7 Portability Defects 7.11 An Example of a Portability Problem
- Realize the superposition display analysis of DWG drawing with CAD in Cesium
- Internet使用的网络协议是什么
- ISC2022 HackingClub白帽峰会倒计时1天!最全议程正式公布!元宇宙集结,精彩绝伦!
猜你喜欢

An online JVM FullGC made it impossible to sleep all night and completely crashed~

JS Improvement: Handwritten Publish Subscriber Model (Xiaobai)

CS-NP白蛋白包覆壳聚糖纳米颗粒/人血清白蛋白-磷酸钙纳米颗粒无机复合材料

使用员工管理软件,解锁人力生产力新水平,提高人力资源团队灵活性

How to choose Visibility, Display, and Opacity when interacting or animating

Transplant MQTT source code to STM32F407 development board

【Jmeter常用断言组件】

磷酸化甘露糖苷修饰白蛋白纳米粒/卵白蛋白-葡聚糖纳米凝胶的

2022牛客多校联赛第五场 题解

用户量大,Redis没法缓存响应,数据库宕机?如何排查解决?
随机推荐
C陷阱与缺陷 第7章 可移植性缺陷 7.8 随机数的大小
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.1 The Prehistoric Phase of the C Language
Popular explanation: what is a clinical prediction model
MySQL 中出现的字符编码错误 Incorrect string value: ‘\x\x\x\x‘ for column ‘x‘
C专家编程 第1章 C:穿越时空的迷雾 1.1 C语言的史前阶段
织梦模板加入php代码
How to choose Visibility, Display, and Opacity when interacting or animating
相亲模型与有限状态机
使用员工管理软件,解锁人力生产力新水平,提高人力资源团队灵活性
线上一次JVM FullGC搞得整晚都没睡,彻底崩溃~
JS提升:手写发布订阅者模式(小白篇)
How to make the timer not execute when the page is minimized?
对C语言结构体内存对齐的理解
【Unity实战100例】文件压缩Zip和ZIP文件的解压
使用百度EasyDL实现厂区工人抽烟行为识别
PX4模块设计之十五:PX4 Log设计
kubernetes各名词缩写
测试的意义并不是能找到全部的缺陷
C陷阱与缺陷 第5章 库函数 5.5 库函数signal
idea实用快捷键合集——持续更新