In codeblocks:
-----------------------------------------------------------------------------------
//program to search a string in given list of strings
#include <stdio.h>
#include<string.h>
int main()
{
char string[100][100],st[100];
int i,n,flag=0;
printf("enter n\n");
scanf("%d",&n);
printf("enter strings\n");
for(i=0;i<=n-1;i++)
{
scanf("%s",string[i]);
}
printf("enter string to be searched\n");
scanf("%s",st);
for(i=0;i<=n-1;i++)
{
if(strcmp(string[i],st)==0)
{
flag=1;break;
}
}
if(flag==1)
{
printf("found and location=%d",i);
}
else
{
printf("not found");
}
return 0;
}
-------------------------------------------------------------------------------
In turboc++
----------------------------------------------------------------------------------------------------------
//program to search a string in given list of strings
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
char string[100][100],st[100];
int i,n,flag=0;
printf("enter n\n");
scanf("%d",&n);
printf("enter strings\n");
for(i=0;i<=n-1;i++)
{
scanf("%s",string[i]);
}
printf("enter string to be searched\n");
scanf("%s",st);
for(i=0;i<=n-1;i++)
{
if(strcmp(string[i],st)==0)
{
flag=1;break;
}
}
if(flag==1)
{
printf("found and location=%d",i);
}
else
{
printf("not found");
}
getch();
return 0;
}
-----------------------------------------------------------------------------------
//program to search a string in given list of strings
#include <stdio.h>
#include<string.h>
int main()
{
char string[100][100],st[100];
int i,n,flag=0;
printf("enter n\n");
scanf("%d",&n);
printf("enter strings\n");
for(i=0;i<=n-1;i++)
{
scanf("%s",string[i]);
}
printf("enter string to be searched\n");
scanf("%s",st);
for(i=0;i<=n-1;i++)
{
if(strcmp(string[i],st)==0)
{
flag=1;break;
}
}
if(flag==1)
{
printf("found and location=%d",i);
}
else
{
printf("not found");
}
return 0;
}
-------------------------------------------------------------------------------
In turboc++
----------------------------------------------------------------------------------------------------------
//program to search a string in given list of strings
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
char string[100][100],st[100];
int i,n,flag=0;
printf("enter n\n");
scanf("%d",&n);
printf("enter strings\n");
for(i=0;i<=n-1;i++)
{
scanf("%s",string[i]);
}
printf("enter string to be searched\n");
scanf("%s",st);
for(i=0;i<=n-1;i++)
{
if(strcmp(string[i],st)==0)
{
flag=1;break;
}
}
if(flag==1)
{
printf("found and location=%d",i);
}
else
{
printf("not found");
}
getch();
return 0;
}