20120113

Program in C++ to learn array of pointer, arrofptr.cpp

//========================
//Program in C++ to learn  array of pointer, arrofptr.cpp
//========================
#include<iostream>
using namespace std;
#include<string.h>
#include<ctype.h>
int main()
{
cout<<"\n declaring array of pointer \n";
char * arrptr[10]={"internet", "net", "Music", "TV"};
// above arrptr is array of 10 pointers to character elements
char arrchar[15];
cout<<"Enter ur favorite time pass: \n";
cin>>arrchar;
int i;
for(i=0;i<4;i++)
{
        if(!strcmp(*arrptr[i], arrchar))
        {
        cout<<"Your fav time pass is available here"<<"\n";
        break;
        }
}
//cout<<"Adress of a is : \n"<<ptr1<<"\n";
//cout<<"Address of ptr1 is: \n"<<ptr2<<"\n";
return 0;
}

No comments:

Post a Comment