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 the parts of c program?

1103


What are Macros? What are its advantages and disadvantages?

1168


What is difference between array and pointer in c?

1098


What is pointer & why it is used?

1123


What is gets() function?

1138


Why is c known as a mother language?

1243


write a c program to calculate sum of digits till it reduces to a single digit using recursion

3314


How is null defined in c?

1156


Define recursion in c.

1288


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

1124


What is string function in c?

990


What does it mean when a pointer is used in an if statement?

1111


What the advantages of using Unions?

1233


What do you mean by Recursion Function?

1130


How the c program is executed?

1162