3 Ways to Concatenate String in C++ with 4 Examples
In order to concatenate or combine two or more strings in C++, you may use different ways. These include:
Using + operator
A predefined library function append()
By using strcat() function
In order to concatenate or combine two or more strings in C++, you may use different ways. These include:
Using + operator
A predefined library function append()
By using strcat() function
In the previous tutorial, we learned using the for loop in C++ if we know how many times to execute a block of code.
The C++ while loop is used to execute a block of code until a certain condition is true.
The switch case is another decision-making statement that allows you to execute one or a block of statements as a certain condition is true. The switch statement is used with the case statement
In this tutorial, we will learn how to delay the execution of code in C++ programs. The following function are explained with examples below:
Sleep() function
sleep_for()
usleep()
In C++, you may sort the vector by using the sort() function. This is defined in the
The string find() function in C++ is used to find a substring in the given string.
The find() function belongs to the C++ string class.
We must include
The float is one of the available data types in C++.This is used to store floating point numbers in variables.It’s a numeric literal – in the exponent or fractional form. For example, 10.5.
In this short tutorial, I am going to show how to generate random numbers between 1 to 10 in C++ with two examples.
One of the ways to get the length of an array is using the sizeof() operator in C++.
There are other ways that you may use to get the array length:
By using pointers hack
size() function in STL
By using the begin() and end() functions of Standard Library
C++ getline() function is defined in the string.h header file which is used to take user input in single as well as multi-lines.
In this tutorial, I will show you examples of calculating the square by writing your own logic as well as the built-in functions provided in the math library.
“Foreach” loop (also range-based for loop) is a way to iterate through array, vectors or other datasets/range in C++.
In this tutorial, we will show you how to swap numbers in C++ in the following ways:By using swap functionBy using the temporary variableUsing + and 1 Using * and /
The While loop is used to execute a block of code until a specified condition is true. Alternatively, you can say, if the execution of the specified code repeatedly is not fixed then we use a while loop.
Purpose of break statement The break statement is used to exit the for, while, do-while loops, and switch statements. As we iterate through a C++ while or for loop and the break statement is executed, the control moves outside of the loop to the next statement (if written). In case of break statement executes inside … Read more