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 |
What is ## preprocessor operator in c?
What is main () in c language?
What is a null pointer in c?
When can a far pointer be used?
write a program to read a number and print in words that is in sentence for example 21,219 then output is "twenty one thousand and two hundred nineteen" by using only control flow statements (only loops and switch case )?
What do you mean by Recursion Function?
Explain how do you print an address?
Can a binary search tree be used as an index? If yes, how? Explain
What is array within structure?
Are comments included during the compilation stage and placed in the EXE file as well?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
coding for Fibonacci.?