program to locate string with in a string with using strstr
function

Answer Posted / gmail

#include<iostream.h>
#include<conio.h>
void main()
{
char str1[15],str2[15];
clrsacr();
cout<<"Enter a string";
cin>>str1;
cout<<"\nEnter another string to be located";
cin>>str2;
int n;
n=strstr(str1,str2);
if(n==0)
cout<<"\nstring not locatd";
else
cout<<"At location "<<(n+1);
getch();
}

Is This Answer Correct ?    3 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a string and an array?

711


What are actual arguments?

652


write a c program for swapping two strings using pointer

2098


What is the purpose of sprintf?

625


What are pointers in C? Give an example where to illustrate their significance.

754






What is a spanning Tree?

966


What are the disadvantages of external storage class?

594


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

1921


Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.

1599


What are the types of macro formats?

613


What does c mean in standard form?

604


What is the use of function in c?

715


What kind of structure is a house?

562


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

1646


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

985