Previous: Chapter 11
Up: Chapter 11
Previous Page: Chapter 11
Next Page: 11.1 The Data Type STRING
These days, computers are not used only for processing numbers, but,
as we have seen in previous chapters, they are also used for processing
textual data.
As we saw in Chapter , in C, textual data is represented
using arrays of characters called a string.
If we are to manipulate strings in any reasonable way we must have several
basic operations available to us. Since string is not a basic type in C, string
operations must be developed as functions. A library of such functions can then
be used as a part of the language. In other words, we can effectively treat
string as an abstract data type
once we have string operations written in function form.
The Standard Library provides a rich set of functions for performing
operations on strings such as copying and comparing them, breaking
strings up into parts, joining them, finding substrings, substituting one
string for another, and so forth. In this chapter, we will discuss such string
processing using the built-in library functions as well as look at how
some of these functions can be written.
We begin the chapter by defining a user defined data type for strings and then use this new type throughout. We then describe the library functions available for performing string operations, including reading and writing strings, copying a string and finding its length, comparing and joining strings and converting the information in a string to other data types. We conclude the chapter with several example programs using these string operations.