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
Give differences between - new and malloc() , delete and free() ?
what are the 10 different models of writing an addition program in C language?
Explain the difference between strcpy() and memcpy() function?
Difference between strcpy() and memcpy() function?
Explain what is the use of a semicolon (;) at the end of every program statement?
how do you execute a c program in unix.
Why is c called a mid-level programming language?
Explain the advantages of using macro in c language?
What is wrong in this statement? scanf(“%d”,whatnumber);
What is the newline escape sequence?
string reverse using recursion
in linking some of os executables are linking name some of them
What is a void * in c?
Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix
i have a written test for microland please give me test pattern