The String Data Type


The string datatype is a built in type. A string may be declared as shown below.

my_string = "this is an example of a string"
cout << my_string

The string is printed to the console using the stream cout

It is often useful to concatenate strings. This may be done as shown below.

my_string_a = "this is an example of a string"
my_string_b = " and this is another example of a string"
my_string_c = my_string_a + my_string_b
cout << my_string_c

The integer and number datatypes have a to_string() method which converts the numeric type to a string. This has been used in the samples to date.