Thursday, 21 September 2017

Array of pointers to charecter in C++

/*
 Array of poniters to character
*/

#include "iostream"
using namespace std;
const int MAX=3;

int main(){
 char *name[MAX] = {
  "Pavan",
  "Jaiswal",
  "Pune" };
 cout<<"\n Printing character array elements \n";
 for(int i=0; i<MAX; i++){
  cout<<" "<<name[i]; // *name[i] prints first character of each string, say P J P
 }
 cout<<endl;
 return 0;
}
 
 /*
 OUTPUT
[pavan@localhost Home]$ g++ ArrayOfPointerChar.cpp
[pavan@localhost Home]$ ./a.out 

 Printing character array elements 
 Pavan Jaiswal Pune
[pavan@localhost Home]$ 

*/

No comments: