1. Write a C program to count the number of occurrence
of
a specific word in the given strings.
(for e.g. Find how many times the word “live” comes in the
sentence “Dream as if you’ll live forever, live as if
you’ll die today ”)
Answer Posted / ram
#include <string.h>
void main()
{
char name[] ="Dream as if you will live forever, live as if
you will die today";
char r[] ="live";
int iLen = strlen(r);
int iCount = 0;
while(1)
{
if( strstr(name,r) == NULL)
break;
strcpy(name, strstr(name,r));
strcpy(name,name+iLen);
iCount++;
}
printf("%d",iCount);
}
Is This Answer Correct ? | 23 Yes | 28 No |
Post New Answer View All Answers
what will be maximum number of comparisons when number of elements are given?
How can I do graphics in c?
Define VARIABLE?
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?
Are enumerations really portable?
What is the advantage of a random access file?
Is it better to bitshift a value than to multiply by 2?
What is the meaning of c in c language?
When do we get logical errors?
How can a process change an environment variable in its caller?
List out few of the applications that make use of Multilinked Structures?
What’s a signal? Explain what do I use signals for?
How can you determine the maximum value that a numeric variable can hold?
Differentiate between declaring a variable and defining a variable?
What is dynamic variable in c?