#include<stdio.h>
#include<conio.h>
int strchr(char [],char );
void main()
{
char a[80],b;
int i;
clrscr();
printf("Enter 1st string\n");
gets(a);
printf("Enter character to find occurence\n");
fflush(stdin);
scanf("%c",&b);
i=strchr(a,b);
if(i!=0)
printf("The character occured at %d position\n",i);
printf(" Sorry! the character is not present in the string");
getch();
}
int strchr(char a[],char y)
{
int i,j;
for(i=0;a[i]!=y&&a[i];i++);
if(a[i]=='\0')
return (0);
return(i);
}
Subscribe to:
Post Comments (Atom)
Related Post
Array:
String functions:
General (Loops-for/while)
No comments:
Post a Comment