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 |
#include<stdio.h> void main() { int a [5]; for (i=0; i<=4; i++) printf(“%d” ,a[i]); }
What is a memory leak in structures? How can we rectify that?
What is the use of c language in real life?
Why can arithmetic operations not be performed on void pointers?
How can I send mail from within a c program?
how logic is used
Given an array of characters, how would you reverse it? How would you reverse it without using indexing in the array?
write a program to copy the string using switch case?
Write a c code segment using a for loop that calculates and prints the sum of the even integers from 2 to 30, inclusive?
#include<stdio.h> main() {int i=1;j=1; for(;;) {if(i>5) break; else j+=1; printf("\n%d",j) i+=j; } }
What are the uses of pre-processor directives?
Differentiate between functions getch() and getche().