We already learnt about strings in C++ Data-types, Operators and Strings, but in this tutorial we are going to learn a little more about C++ strings and also see some helpful functions C++ provides for strings.
String literals are enclosed in either double quotes.
For example, "Hello World" is a string.
To type in some special characters, you have to type in a backslash escape. For example, \" is a double quote, \\ is a backslash, \t is a tab and \n is a newline. For example, the following code:
cout << "Alice said \"How do you do?\"\nBob replied, \"Very well thank you!\"";
In this tutorial, we'll learn about different types of containers in C++. In particular, we will learn about vectors, maps and pairs in C++.
Earlier, you learnt about C++ Arrays. Vectors are like arrays, but they are more flexible. In particular, you might remember that it is not possible to change the size of a C++ array after it is declared. Vectors provide us the flexibility of inserting and deleting elements even after they are declared.
Declaring a Vector
Suppose you are taking a survey of 100 people and you have to store their age. To solve this problem in C++, you can create a vector of integers with 100 elements. For example:
In this tutorial, you'll learn about arrays and loops in C++. Both of these are very important concepts in programming. In plain English, loop-statements correspond to “Do this action X times.” or “Keep doing that action as long as this condition is true.” But let's learn about arrays first.
The variables you saw so far in the course only stored a single number or string. What if we wanted to store multiple numbers or strings? This is exactly what an Array does.
Arrays are collections of values of a single type stored together (we cannot have an array containing numbers and strings together). In this article, you will learn to declare, initialize and access array elements.
Declaring an array
Suppose you are taking a survey of 100 people and yo...