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 diffrence between string and character array?
what is bit rate & baud rate? plz give wave forms
There seem to be a few missing operators ..
which one is not preprocessor directive a)#if b)#elif c)#undef d)#pragma
16 Answers Accenture, Infosys, TCS, Wipro,
Explain the use of function toupper() with and example code?
What is the use of function overloading in C?
pgm in c to reverse string by word using array(god is love becomes love is god) (no additional array can used,space is only delimiter between words )
write a program to display the numbers having digit 9 in the given range from 1 to 100
how would a 4*3 array A[4][3] stored in Row Major Order?
What is Lazy evaluation in C? Give an example.
Differentiate Source Codes from Object Codes
What is wrong with this initialization?