<pre>
<strong>Program for searching a character in a string.</strong>
<p>/*Program for searching a character in a string*/
#include<stdio.h>
#include<conio.h>
void main()
{
char str[20],ch;
int cnt=0,i;
clrscr();
printf(“nnntt Program for searching a character in a string”);
printf(“nnnttt Enter a string = “);
scanf(“%s”,&str);
printf(“nttt Enter the character to search = “);
flushall();
scanf(“%c”,&ch);
for(i=0;str[i]!=”;i++)
{
if(str[i]==ch)
cnt++;
}
if(cnt==0)
printf(“nnttt The character ‘%c’ is not found in the string…”,ch);
else
printf(“nnttThe character ‘%c’ is occurring %d times in the string.”,ch,cnt);
getch();
}
</p>
</pre>