Write a program in C++ returning starting locations of a
substring using pointers
Answer / pramod
#include<stdio.h>
#include<iostream.h>
int main()
{
char* mystrstr(char*,char*);
char str1[20];
char str2[10];
cout<<"\n Enter two strings\t";
cin>>str1>>str2;
cout<<"\nstr1 = "<<str1<<" str2 "<<str2 ;
char* c= mystrstr(str1,str2);
if(c!=NULL)
printf("\nc = %s\n",c);
return 0;
}
char* mystrstr(char* str1, char* str2)
{
char *cp = (char *) str1;
char *s1, *s2;
if ( !*str2 )
return((char *)str1);
while (*cp)
{
s1 = cp;
s2 = (char *) str2;
while ( *s1 && *s2 && !(*s1-*s2) )
{
s1++;
s2++;
}
if (!*s2)
{
printf("\n string found\n");
return(cp);
}
cp++;
}
return(NULL);
}
| Is This Answer Correct ? | 8 Yes | 9 No |
What is stl stand for?
write a program that will accept a number and print.its equivalent in words the maximum input number is 9999
What do you mean by stl?
WHAT IS THE DIFFERENCE BETWEEN C++ AND VC++
totoo po ba ang manga aliens!
When did c++ add stl?
Is stl open source?
How do I convert a stl file?
Is string part of stl?
What Is Operator Overloading in C++?
write a program to search and display the position of an element in a single-dimentional array using function.
What does stl mean in slang?