Section 8.5 - Unbounded String Basics

The Unbounded_String type is defined in the package Ada.Strings.Unbounded, so you'll need to ``with'' package Ada.Strings.Unbounded to use the Unbounded_String type. Package Ada.Strings.Unbounded also provides a number of useful basic operations on Unbounded_String. The Ada LRM provides a complete definition of package Ada.Strings.Unbounded.

Here are a few important operations:

Comparison operations (such as "=" and "<") are defined in this package. There are other routines to modify or search Unbounded_Strings, including "&" (concatenate two Unbounded_Strings together), Translate, Trim, Head, Tail, Index, and Find_Token. We'll discuss those operations later.

Because of the way Unbounded_String is defined, you can use assignment (:=) as well.


Quiz:


Given a variable ``Input'' of type Unbounded_String, what expression would return the value of the fourth character in Input?
  1. Element(Input, 4)
  2. Replace_Element(Input, 4, 'L')
  3. Element(4, Input)

You may also:

PREVIOUS Go back to the previous section

NEXT     Skip to the next section

OUTLINE  Go up to the outline of lesson 8

David A. Wheeler (wheeler@ida.org)