C++ Convert Char Array to String - Tutorial Kart

C++ Char Array to String

C++ Char Array to String

In this tutorial, we shall write C++ Programs that convert char array to string. There are many ways to convert a string to an array of characters. We shall go through some of them.

Method 1: Assign String Literal to the Char Array

To convert a char array to string, you can directly assign the char array with list of characters, to the string variable.

C++ Program

#include using namespace std; int main() {

string str = {'t','u','t','o','r','i','a','l','k','a','r','t'}; cout ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download