Answer Posted / 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 View All Answers
Explain what are header files and explain what are its uses in c programming?
What is a substring in c?
What is the difference between array and structure in c?
What does the && operator do in a program code?
What are pointers? What are different types of pointers?
What is the size of empty structure in c?
What is c mainly used for?
What is a pointer value and address in c?
Why do we need a structure?
How will you divide two numbers in a MACRO?
What are near, far and huge pointers?
Explain what is output redirection?
How can I recover the file name given an open stream?
Explain the difference between ++u and u++?
Why c is known as a mother language?