美文网首页
Learn C the Hard Way 目录

Learn C the Hard Way 目录

作者: 爱跑步的coder | 来源:发表于2018-06-14 08:26 被阅读0次

Undefined Behaviorists

solid(2 + 2 secure) = 4

Undefined Behavior(1 + 10 UB) = 11
 At the end of string occur UB.
 Since many strings come from outside the program, it’s common for a C program to receive a string without this NULL byte.
 When it does, the C program attempts to read past the end of this string and into the memory of the computer, causing your program to crash.

avoid(3 + 4 prevent) = 7

However, you should keep in mind that avoiding the nearly random nature of UB is almost impossible, and you’ll just have to do your best.

C Is a Pretty and Ugly Language

elegant(3) = 3
solid(3) = 3
power(4) = 4
defensive programming

I approach C, and any programming, with the idea of preventing errors as best I can and assuming that nothing will work right.

All code is flawed, but the difference is that I try to assume my code is always flawed and then prevent the flaws.

相关文章

网友评论

      本文标题:Learn C the Hard Way 目录

      本文链接:https://www.haomeiwen.com/subject/jsjeeftx.html