C++ Convert String to Char Array - Tutorial Kart

C++ String to Char Array

C++ String to Char Array

In this tutorial, we shall write C++ Programs that convert string to char array. 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 string to char array, you can directly assign the char array variable with a string constant.

C++ Program

#include using namespace std; int main() {

char charArr[] = "tutorialkart"; for(char ch: charArr)

cout ................
................

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

Google Online Preview   Download