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 ? | 7 Yes | 9 No |
method overloading means what?
Write a program in C++ returning starting locations of a substring using pointers
What is the disadvantage of templates ?
write a c++ to define a class box with length,breadth and height as data member and input value(),printvalue() and volume() as member functions.
what is electronic software
Describe the elements of Microsoft Word screen. Write down steps for creating, saving, retrieving, editing and printing a document.
How can you create a bulleted list, numbered list and an outline by using bullets and numbering command. Explain with the help of example.
what is strcture i++ i ++i answer to this i=5 what is the out put
What is meant by stl in c++?
Write a program in C/C++ to implement reader- writer problem
What is stl language?
Assume I have a linked list contains all of the alphabets from "A" to "Z?" I want to find the letter "Q" in the list, how does you perform the search to find the "Q?"