Prints strings pointed to by an array. - C++ Data Type

C++ examples for Data Type:Array Pointer

Description

Prints strings pointed to by an array.

Demo Code

#include <iostream>
using namespace std;
void main()//from  w ww  . j  a  v  a 2  s . c  o m
{
   char *name[5]={ {"George"},{"Michelle"},{"Joe"}, {"Marcus"},{"book2s.com"} };
   int ctr;
   for (ctr=0; ctr<5; ctr++)
   {
      cout << "String #" << (ctr+1) <<" is " << *(name+ctr) << "\n";
   }
   return;
}

Result


Related Tutorials