© Giulio Zambon 2016

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

6. String Utilities

Giulio Zambon

(1)Harrison, Aust Capital Terr, Australia

In C strings are null-terminated arrays of characters. You can manipulated them with a series of functions declared in the standard header file string.h, but there are two drawbacks:

  • The only way of defining new C strings at runtime is to allocate memory from the heap, and you are responsible for freeing the allocated memory when you no longer need the string. Failure to do so results in memory leaks that, over time, consume all the available memory and cause crashes. A common mistake associated with dynamically allocated strings is freeing a block of memory before you are done with it: everything ...

Get Practical C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.