in turboc++
--------------------------------------------------------------------------------------
//WAP to compare two strings using(strchr()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
char st[100],st1;//two string declaration
char *p;
printf("enter string\n");
gets(st);
printf("enter a character to look for\n");
st1=getchar();//inputs
if(strchr(st,st1))//
{
p=strchr(st,st1);
printf("strchr(st,st1)=%d\n",*p);
printf("%c is in given string,location=%d ",st1,p-st);
}
else
{
printf("not in given character");
}
getch();
return 0;
}
---------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------
//WAP to compare two strings using(strchr()) function.
#include <stdio.h>
#include<string.h>
int main()
{
char st[100],st1;//two string declaration
char *p;
printf("enter string\n");
gets(st);
printf("enter a character to look for\n");
st1=getchar();//inputs
if(strchr(st,st1))//
{
p=strchr(st,st1);
printf("strchr(st,st1)=%d\n",*p);
printf("%c is in given string,location=%d ",st1,p-st);
}
else
{
printf("not in given character");
}
return 0;
}
--------------------------------------------------------------------------------------
//WAP to compare two strings using(strchr()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
char st[100],st1;//two string declaration
char *p;
printf("enter string\n");
gets(st);
printf("enter a character to look for\n");
st1=getchar();//inputs
if(strchr(st,st1))//
{
p=strchr(st,st1);
printf("strchr(st,st1)=%d\n",*p);
printf("%c is in given string,location=%d ",st1,p-st);
}
else
{
printf("not in given character");
}
getch();
return 0;
}
---------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------
//WAP to compare two strings using(strchr()) function.
#include <stdio.h>
#include<string.h>
int main()
{
char st[100],st1;//two string declaration
char *p;
printf("enter string\n");
gets(st);
printf("enter a character to look for\n");
st1=getchar();//inputs
if(strchr(st,st1))//
{
p=strchr(st,st1);
printf("strchr(st,st1)=%d\n",*p);
printf("%c is in given string,location=%d ",st1,p-st);
}
else
{
printf("not in given character");
}
return 0;
}
No comments:
Post a Comment