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 |
why we are using the fork command?.. how it works?
What is the Difference between CArray and CList?
1 Answers ProdEx Technologies, Siemens,
Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fork(); if(!ret) printf("sun"); else printf("solaris");
WHAT IS FIBONACCI SERIES?
Find the error in the following program struct point {struct point *next; int data; } x; main() {int...data; } x; main() {int i; for(x=p;x!=0;) x=x->next,x++; freelist(x); } freelist(x) {free(x); return }
Distinguish between: a) Normal layout & Print Layout views b) Windows Clipboard & office Clipboard c) Save & Save As Commands d) Program File & Data File e) Pie Charts & Barr Charts
write a program to demonstrate,how constructor and deconstructor work under multilevel inheritance
What is a stl vector?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
what is compiler?
if 4-5 year old brother is standing on d roof with me and watching d moon, suddenly moon coverd by cloud then how will i explain d hiding of moon to my brother.
What are the components of stl?