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 are qualifiers and modifiers c?
Is exit(status) truly equivalent to returning the same status from main?
Why double pointer is used in c?
When should structures be passed by values or by references?
what is reason of your company position's in india no. 1.
What is return type in c?
How can I find out how much free space is available on disk?
What are the advantage of c language?
What’s a signal? Explain what do I use signals for?
What are identifiers c?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
write a c program for swapping two strings using pointer
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
program for reversing a selected line word by word when multiple lines are given without using strrev