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

Why does everyone say not to use gets?

1026


Why do we use header files in c?

1016


How can you increase the size of a dynamically allocated array?

1131


What do you mean by a sequential access file?

1041


Which built-in library function can be used to match a patter from the string?

1236


How can I make sure that my program is the only one accessing a file?

1189


What are the restrictions of a modulus operator?

1062


Do you know the purpose of 'register' keyword?

966


How do you determine the length of a string value that was stored in a variable?

1078


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1017


What does main () mean in c?

1055


What are bitwise shift operators in c programming?

1037


application attempts to perform an operation?

1914


Is c a great language, or what?

1049


What are the benefits of organizational structure?

972