Array of pointers
#include<bits/stdc++.h>
using namespace std;
int main()
{
char *ptr[]={"ujjal","roy","ujjal"};
char s[]="ujjal";
for(int i=0;i<3;i++)
{
if(!strcmp(s,ptr[i]))
{
cout<<"found\n";
return 0;
}
}
cout<<"Not found\n";
return 0;
}
Array of pointers
#include<bits/stdc++.h>
using namespace std;
int main()
{
char *ptr[]={"ujjal","roy","ujjal"};
char s[]="ujjal";
for(int i=0;i<3;i++)
{
if(!strcmp(s,ptr[i]))
{
cout<<"found\n";
return 0;
}
}
cout<<"Not found\n";
return 0;
}
0 Comments