© Giulio Zambon 2016

Giulio Zambon, Practical C, 10.1007/978-1-4842-1769-6_7

7. Dynamic Arrays

Giulio Zambon

(1)Harrison, Aust Capital Terr, Australia

The size of arrays in C is set at compile time. In the previous chapter, you learned a way of defining dynamically allocated C strings, which are arrays of characters. In this chapter, you will see how you can define at runtime arrays of any type. If you haven’t read Chapter 6, I suggest that you quickly go through it, so that you can use it as a reference for this chapter.

That said, it doesn’t mean that you can immediately convert the string functions and macros of Chapter 6 to work with any type of element because the conversion would present two immediate obstacles:

  • C strings are null-terminated, ...

Get Practical C now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.