Introduction to String
You can also store text in variables, in addition to symbols using char
. For this, you need to:
- Connect the
string
file; - Use std scope resolution;
- Declare a variable of type
string
.
main.cpp
Strings variables can also contain numbers (as text):
main.cpp
If you try to add two string variables, you get a concatenation (it works without spaces):
main.cpp
The same thing will happen with numbers – they will not be added algebraically.
¿Todo estuvo claro?
Contenido del Curso
C++ Introduction
4. Introduction to Program Flow
5. Introduction to Functions
C++ Introduction
Introduction to String
You can also store text in variables, in addition to symbols using char
. For this, you need to:
- Connect the
string
file; - Use std scope resolution;
- Declare a variable of type
string
.
main.cpp
Strings variables can also contain numbers (as text):
main.cpp
If you try to add two string variables, you get a concatenation (it works without spaces):
main.cpp
The same thing will happen with numbers – they will not be added algebraically.
¿Todo estuvo claro?