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 |
The code is::::: if(condition) Printf("Hello"); Else Printf("World"); What will be the condition in if in such a way that both Hello and world are printed in a single attempt?????? Single Attempt in the sense... It must first print "Hello" and it Must go to else part and print "World"..... No loops, Recursion are allowed........................
14 Answers HOV Services, IBM, Potty,
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
How do you determine the length of a string value that was stored in a variable?
application attempts to perform an operation?
Write code for finding depth of tree
What is getch c?
What is scope rule of function in c?
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
0 Answers College School Exams Tests,
What are the different types of errors?
What's a good way to check for "close enough" floating-point equality?
What is the difference between procedural and functional programming?
Why is main function so important?