String In C++

A string is an array of type char.

Declaration:-  char variable_name[size];


char name [20];


Initializing of character array


char name [4] = “David”;

A program to initialize a set of characters in one dimensional character array and to display the contents of the array.

Void main ()
Int I;
Char name [4] = {‘d’, ‘a’, ‘v’, ‘I’, ‘d’};
Cout<<”\n contents of the array”;
For (i=0; i<4; i++)
getch ();

Related posts:

  1. Arrays In C++ Arrays in C++ Array is a collection of similar type...
  2. Passing Arrays To Functions Passing arrays to functions Array can be passed as argument...
  3. Array Of Class Object Array of class objects Array is a collection of similar...
  4. Defining Member Function In C++ Class methods definitions  (Defining the member functions) Member functions can...
  5. C++ Object Initialization Dynamic initialization of objects in c++ The dynamic initialization means...