Strings

  • Sequence of characters enclosed in double quotes

  • A one-dimensional character array can be used to store a string (as long as it ends with a null character \0)

Declaration

  1. Vector declaration of a char vector with length length

  1. Dynamic allocation dynamic allocation of a memory area of length bytes, which is organized as a char sequence (1 Byte each)

Inizialization

  1. With implicit size

    where the length of the string is:

  2. With explicit size

    • if length >= (num_string_characters + 1), the string occupies the "value" number of characters + 1 (/0)

    • else KILLED PROCESS

Vector of strings

  1. With an array

  2. With a pointer

Initialization

  1. With an array

    where:

    • array_size: number of strings in the vector (# of elements)

    • string_size: maximum number of characters for the strings

    One or both the parameters can be omitted and are retrieved automatically.

  2. With a pointer

    It implicitly calculates both the number of strings and the number of characters in each individual string (by evaluating the values on the left)

Last updated