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...

Write a c program to find, no of occurance of a given word
in a file. The word is case sensitive.

Answer Posted / ashutosh shashi

//function return occurance of word
int findoc(char* str,char* str1)
{
char* temp = str1;
int count =0;
while(*str != NULL)
{
while((*str == *temp)&&(*temp != NULL))
{
str++;
temp++;
if(*temp == NULL)
count++;
}
temp = str1;
if(*str != *temp)
str++;
}
return count;
}

///if function is called like

char* str = "ashashushuaashu";
char* str1 = "ashu";
int count = findoc(str,str1);
printf("%d",count);
///it prints 2, because str1 is appears 2 times in str

Is This Answer Correct ?    1 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 5 types of inheritance in c ++?

1028


can any one provide me the notes of data structure for ignou cs-62 paper

2180


Why is #define used?

1281


What is the use of function in c?

1197


What are the restrictions of a modulus operator?

1129


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

3095


What is derived datatype in c?

1099


What is the difference between text files and binary files?

1353


Does c have circular shift operators?

1257


Write a program to reverse a given number in c language?

1124


When can you use a pointer with a function?

1080


What is data structure in c and its types?

1072


Sir i need notes for structure,functions,pointers in c language can you help me please

2425


What is the difference between a free-standing and a hosted environment?

1152


How can I read in an object file and jump to locations in it?

1035