Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are terms in math?

1044


What is string constants?

1143


What is the difference between text files and binary files?

1346


What are the restrictions of a modulus operator?

1119


Who developed c language and when?

1060


What is an expression?

1051


Which is the best website to learn c programming?

1075


Explain what is gets() function?

1069


What are different types of pointers?

1065


What is the explanation for prototype function in c?

975


When a c file is executed there are many files that are automatically opened what are they files?

1105


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1988


Are the outer parentheses in return statements really optional?

1111


What does the characters “r” and “w” mean when writing programs that will make use of files?

1472


Explain what are the different file extensions involved when programming in c?

1107