In this C++ tutorial, you will get an introduction to strings in C++ programming language. There are also a list of tutorials that get you started with the basics of strings, and then cover the most commonly used string operations.
In C++, String is an object of class type
std::string. This type of object represents a sequence or string of characters, hence called a string.
The following is an example for a string.
This string contains 11 characters. In C++, the string constant is enclosed in double quotes.
string keyword is used to specify the datatype of a variable.
string s = "Hello World";
In this tutorial, we will go through most used C++ String Operations with examples.
C++ String Tutorials
The following are tutorials based on string operations, and are categorized based on the type of operations done at string level, or character level.
- C++ Check if string is empty
- C++ Check if strings are equal
- C++ Check if string contains specific substring
- C++ Check if string contains specific character
- C++ Check if string contains only digits
- C++ Check if string contains only spaces
- C++ Check if string contains only certain character
- C++ Check if string starts with specific prefix
- C++ Check if string ends with specific suffix
- C++ Check if string is number
- C++ String comparison
The following tutorials cover use cases where part or whole of the string value is manipulated.
- C++ Append string
- C++ Concatenate strings
- C++ String reverse
- C++ String replace
- C++ Swap strings
- C++ Convert string to uppercase
- C++ Convert string to lowercase
- C++ Repeat string N times
Character Level Manipulations
- C++ String – Append character at the end
- C++ String – Append character at beginning
- C++ String – Insert character at specific index
- C++ String – Remove first character
- C++ String – Remove last character
- C++ String – Replace specific character with another
- C++ String – Remove all occurrences of a specific character
In this C++ Tutorial, we learned how to do some of the String Operations with the help of example programs and detailed tutorials.