Y
yogi_bear_79
I'm sure I have a few things wrong here. But I am stuck on how to do
a recurring search. Also my statement cin >> quote; acts weird. If I
enter more than one word it blows right past cin >> findMe; and
completes and exits the code. If you string for cin >> quote; is one
word it behaves correctly or at least in that regard!
#include <iostream>
#include <string>
using namespace std;
string quote;
string findMe;
int foundIt(string str1, string str2);
int main ()
{
cout << " \n Enter a sentence or two:" << endl;
cin >> quote;
cout << " \n Enter string to search for:" << endl;
cin >> findMe;
cout << foundIt(quote, findMe);
}
int foundIt(string str1, string str2)
{
size_t pos;
int x = 0;
pos = str1.find(str1);
if (pos!=string::npos)
x++;
return x;
}
a recurring search. Also my statement cin >> quote; acts weird. If I
enter more than one word it blows right past cin >> findMe; and
completes and exits the code. If you string for cin >> quote; is one
word it behaves correctly or at least in that regard!
#include <iostream>
#include <string>
using namespace std;
string quote;
string findMe;
int foundIt(string str1, string str2);
int main ()
{
cout << " \n Enter a sentence or two:" << endl;
cin >> quote;
cout << " \n Enter string to search for:" << endl;
cin >> findMe;
cout << foundIt(quote, findMe);
}
int foundIt(string str1, string str2)
{
size_t pos;
int x = 0;
pos = str1.find(str1);
if (pos!=string::npos)
x++;
return x;
}