C++ Program to Initialize and Print String

Write C++ Program to Initialize and Print String

// CPP Program to Initialize and Print String

#include <iostream>

using namespace std;

int main()
{
	cout << "There are total 4 ways to initialize string in c :--> ";

	char S1[]="CodeCrucks";

	char S2[45]="CodeCrucks";

	char S3[]={'C','o','d','e','C','r','u','c','k','s','\0'};

	char S4[45]={'C','o','d','e','C','r','u','c','k','s','\0'};

	cout << "\n\nNo 1 :--> " << S1;
	cout << "\nNo 2 :--> " << S2;
	cout << "\nNo 3 :--> " << S3;
	cout << "\nNo 4 :--> " << S4;

	return 0;
}

Output:

There are total 4 ways to initialize string in c :-->

No 1 :--> CodeCrucks
No 2 :--> CodeCrucks
No 3 :--> CodeCrucks
No 4 :--> CodeCrucks

≪ Previous | Next ≫