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 is the difference between array and structure in c?

1080


Explain the array representation of a binary tree in C.

1164


When we use void main and int main?

1017


Is that possible to store 32768 in an int data type variable?

1031


How can a string be converted to a number?

963


What are pointers? What are different types of pointers?

1057


write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?

2810


What is the use of getch ()?

1034


what will be the output for the following main() { printf("hi" "hello"); }

10790


Can variables be declared anywhere in c?

1034


Explain how are 16- and 32-bit numbers stored?

1207


What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

1814


What is variable in c example?

992


Why doesnt the call scanf work?

1137


why wipro wase

2247