course content

Course Content

Introduction to C++

StringString

In addition to numbers (int, double etc.) and symbols(char) in variables, you can also store text. For this, you need to:

  • Connect the string module;
  • Get the string object from the namespace std;
  • Declare a variable of type string.
cpp

main.cpp

\n – is the new line symbol (same as endl, but a symbol).

Strings variables can also contain numbers (as text):

cpp

main.cpp

If you try to add two string variables, you get a concatenation:

cpp

main.cpp

The same thing will happen with numbers – they will not be added algebraically.

To find out the length of a string, we can use the standard length() function:

cpp

main.cpp

Section 2.

Chapter 4