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
What does 3 periods mean in texting?
What is scope rule of function in c?
Can a void pointer point to a function?
Why do we use int main instead of void main in c?
Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop
what are the different storage classes in c?
What is structure pointer in c?
Is malloc memset faster than calloc?
What is the use of printf() and scanf() functions?
When would you use a pointer to a function?
What is the argument of a function in c?
All technical questions
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
Explain how can a program be made to print the name of a source file where an error occurs?