#Mastery25 A string means an ordered sequence of characters, and in most programming languages such strings are enclosed in either single or double quotes.
In C++ the enclosing delimiters are double quotes. IFor example, the usual first C++ program displays the string literal “Hello, world!” on the screen with the following output statement.
Strings are objects that represent characters, it is actually a one-dimensional array of characters. It is kind of like the same way you declare an array but instead you use characters. Which is the structure of a string?
char name[number of elements] ={‘a’, ‘b’, ‘c’};
or
char name[] ={“abc” };
You can represent a string the same way you represent an array.
1 |
2 |
3 |
a |
b |
c |
A standard library in C++ provides a string class type.
There are other ways to declare a different type of string.
Using namespace std;
String name;
Or
Std:: string name;
A string can be also assigned to each other or appended together using the + operator.
Strings can also be found as compsrisons…
One of the most confusing part of using char*s as strings is that comparisons tricky.
Here is a simple example of the usage of a string;
WATCH MY VIDEO https:/ / youtu.be/ jk3wQsbn3mk
#Mastery25 – Creation and use of strings in C++ by Ricardo Newton is licensed under a Creative Commons Attribution 4.0 International License.