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 is masking?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
Is c still used?
What is meant by operator precedence?
Why can arithmetic operations not be performed on void pointers?
How can I invoke another program or command and trap its output?
What is data structure in c language?
Explain how can type-insensitive macros be created?
1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.
How can I list all of the predefined identifiers?
How are 16- and 32-bit numbers stored?
What is a stream?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
Why is c platform dependent?
Is there a way to switch on strings?