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 own function for strstr



write a own function for strstr..

Answer / abdur rab

#include <stdio.h>

char* str_str ( char* cp_str, char* cp_pattern )
{
char* cp_temp = NULL;
int n_pattern_length = 0;

n_pattern_length = strlen ( cp_pattern );

while ( cp_str && *cp_str ) {
if ( !strncmp ( cp_str, cp_pattern, (
n_pattern_length ) ) ) {
cp_temp = cp_str;
break;
}
else cp_str++;
}

return ( cp_temp );

}

int main ( int argc, char* argv [ ] )
{
char array [] = {"Hello World"};
char* cp_temp = NULL;

cp_temp = str_str ( array, "lo " );
if ( NULL != cp_temp ) {
printf ("\n%s", cp_temp);
} else printf ("\nReturned null");

return ( 0 );

}

Is This Answer Correct ?    12 Yes 7 No

Post New Answer

More C Interview Questions

what is diffrence between string and character array?

1 Answers  


what is bit rate & baud rate? plz give wave forms

0 Answers  


There seem to be a few missing operators ..

0 Answers  


which one is not preprocessor directive a)#if b)#elif c)#undef d)#pragma

16 Answers   Accenture, Infosys, TCS, Wipro,


Explain the use of function toupper() with and example code?

0 Answers  


What is the use of function overloading in C?

0 Answers   Ittiam Systems,


pgm in c to reverse string by word using array(god is love becomes love is god) (no additional array can used,space is only delimiter between words )

2 Answers   Persistent,


write a program to display the numbers having digit 9 in the given range from 1 to 100

1 Answers  


how would a 4*3 array A[4][3] stored in Row Major Order?

0 Answers   HCL, Ignou,


What is Lazy evaluation in C? Give an example.

1 Answers  


Differentiate Source Codes from Object Codes

1 Answers  


What is wrong with this initialization?

0 Answers  


Categories