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

Explain null pointer.

0 Answers  


we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above

0 Answers  


What is operator promotion?

0 Answers  


Write a program to find factorial of a number using recursive function.

0 Answers   Global Logic, TCS,


How to get string length of given string in c?

0 Answers  






what is the output of the following program? #include<stdio.h> void main() { int x=4,y=3,z; z=x-- -y; printf("\n%d %d %d",x,y,z); }

14 Answers  


What are the differences between new and malloc in C?

0 Answers   Amazon,


How do you print an address?

0 Answers   TCS,


what is the difference between normal variables and pointer variables..............

15 Answers   HP, Infosys, Satyam, Vivekanand Education Society,


How can I get Single byte from 'int' type variable? Can we alter single bit or multiple bits in int type variable? if so, How?

2 Answers  


Who invented bcpl language?

0 Answers  


how c source file in converted to exe file

5 Answers   KPIT,


Categories