1And in Conclusion¶
C pointers and arrays are pretty much the same[1], except with function calls.
C knows how to increment pointers.
C is an efficient language, but with little protection:
Array bounds not checked
Variables not automatically initialized
Use handles to change pointers.
Strings are arrays of characters with a null terminator. The length is the # of characters, but memory needs 1 more for \0
Beware: The cost of efficiency is more overhead for the programmer. “C gives you a lot of extra rope, don’t hang yourself with it!”
2Extra References¶
Professor Emeritus Brian Harvey’s notes on C
The biggest difference between arrays and pointers comes down to where they are located in memory; this difference leads to the many details you saw in this chapter. See the next chapter for an overarching framework of memory layout that will help you understand the distinction.