Write a c program to find, no of occurance of a given word
in a file. The word is case sensitive.
Answer Posted / ashutosh shashi
//function return occurance of word
int findoc(char* str,char* str1)
{
char* temp = str1;
int count =0;
while(*str != NULL)
{
while((*str == *temp)&&(*temp != NULL))
{
str++;
temp++;
if(*temp == NULL)
count++;
}
temp = str1;
if(*str != *temp)
str++;
}
return count;
}
///if function is called like
char* str = "ashashushuaashu";
char* str1 = "ashu";
int count = findoc(str,str1);
printf("%d",count);
///it prints 2, because str1 is appears 2 times in str
Is This Answer Correct ? | 1 Yes | 5 No |
Post New Answer View All Answers
What is I ++ in c programming?
What is pointer and structure in c?
why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above
What is meant by operator precedence?
Why n++ execute faster than n+1 ?
What are near, far and huge pointers?
What is the use of volatile?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
Hi can anyone tell what is a start up code?
How can you increase the size of a statically allocated array?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
what are non standard function in c
Write a C program to count the number of email on text
what is the format specifier for printing a pointer value?
List the difference between a 'copy constructor' and a 'assignment operator' in C?