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 |
Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon
What is a far pointer?What is the utility?
how can i sort numbers from ascending order and descending order using turbo c..
what is an inline fuction??
What language is lisp written in?
Can one function call another?
Can a variable be both const and volatile?
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
What is array in c with example?
How can I direct output to the printer?
what is c programming?
Which header file should you include if you are to develop a function which can accept variable number of arguments?