Strings
As we mentioned before strings are used for storing text. Let’s explore some useful functions using this type of variables.
To concatenate 2 (or more) lines to store the result in the new variable, use the operator +
:
9
1
2
3
4
string a = "Hello ";
string b = "World";
string c = a + b;
cout << c;
1234string a = "Hello "; string b = "World"; string c = a + b; cout << c;
String variables contain functions that help perform certain operations on them.
For example, you can find the length of the string variable using the built-in function .length()
:
9
1
2
string a = "Hello user!";
cout << a.length();
12string a = "Hello user!"; cout << a.length();
For finding the length of the line you can use the funtion
.size()
:a.size()
.
You can also concatenate strings using the built-in function .append()
:
9
1
2
string a = "Hello ";
cout << a.append("everyone!");
12string a = "Hello "; cout << a.append("everyone!");
To pick up a draggable item, press the space bar.
While dragging, use the arrow keys to move the item.
Press space again to drop the item in its new position, or press escape to cancel.
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 4
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo