In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you an example analysis of the pitfalls and defects of C language. the content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
I. Preface
Character pointer
Conclusion 1: copying a pointer does not copy what the pointer points to. The two pointers point to the same position and are actually the same pointer.
Conclusion: open up two arrays, even if the contents of the two arrays are the same, the address is not the same.
Third, boundary calculation and asymmetric boundary 1. ① int main () {int I = 0; int arr [10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; for (I = 0; I
< 13; i++) { arr[i] = 0; printf("haha"); } return 0;} 计算的结果是程序陷入死循环 分析: 1.栈区默认先使用高地址,再使用低地址 2.数组内元素随下标增长,地址由低到高变化 调试后即可发现,i与arr[9]的地址相差3字节,所以i即为实际不存在的arr[12]. [补充知识:ANSI c标准允许这种用法--数组中溢界元素的地址位于数组所占内存之后,这个地址可以进行赋值和比较,但是不能解引用(若是数组之前存在溢界则语法不允许)] 2.经典错误② 十米长的围栏每一米就需要一根栏杆支撑,则共需要几根栏杆? 11 3、小结 栏杆问题你若不假思索可能会回答为10。栏杆问题的根源正是加减一带来的困惑 对此我们坚持以下原则 原则一:考虑最简单的特例(如考虑20到10间有几个数,20-10还要+1吗。不妨考虑10到10有几个数) 原则二:仔细计算边界 而在实际编程中,一个编程技巧则可以"一言以蔽之",即不对称边界。 x>= 0 & & x = 0 & & xa)
In this way, the error of dividing zero is avoided.
In particular, the assignment operator does not guarantee any evaluation order, and even if priority and associativity are taken into account, there will be unexpected errors
Int iTuno while (I
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.