Find occurence of a character in a sting.

Answers were Sorted based on User's Feedback



Find occurence of a character in a sting...

Answer / furquan

Use strchr

Is This Answer Correct ?    6 Yes 1 No

Find occurence of a character in a sting...

Answer / anil kumar nahak

void main()
{
char *st,ch;
int i=0,c=0;
printf("\n Enter The String: ");
gets(st);
printf("\n Enter A character For finding occurance: ");
scanf("%c",&ch);

while(st[i]!='\0')
{
if(st[i]==ch)
c++;
i++;
}
printf("\n %c Present In The String %d Times",ch,c);

}

Is This Answer Correct ?    4 Yes 2 No

Find occurence of a character in a sting...

Answer / chanti

strchr()
it is the function which we use in string() while we r
using characters in it.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

What is adt in c programming?

0 Answers  


What is masking?

0 Answers  


What are the types of variables in c?

0 Answers  


write the output of following code .. main() { static int a[]={10,20,30,40,50}; int *ptr=a; static int arr[2][2]={1,2,3,4}; char str[]="ABCD * 4#"; char *s=str+2; int i,j; for(i=0;i<5,i++) printf("%d",*ptr++); for(i=0;i<2;i++) for(j=0;j<2;j++) printf("%d\n",*(*(n+i)+j)); printf("%c\n%c\n%c\n",*(str+2),*s++,*--s); }

1 Answers  


What is a pointer value and address in c?

0 Answers  






There seem to be a few missing operators ..

0 Answers  


i got 75% in all semester am i eligible for your company

0 Answers   Infosys,


Explain is it better to bitshift a value than to multiply by 2?

0 Answers  


write the function int countchtr(char string[],int ch);which returns the number of timesthe character ch appears in the string. for example the call countchtr("she lives in Newyork",'e') would return 3.

6 Answers  


What is advantage of pointer in c?

0 Answers  


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

0 Answers  


Where can I get an ansi-compatible lint?

0 Answers  


Categories