I want to count how many times a quoted string appears in a string.Today "is" a new day "because" it is "12" am.
A string like this should evaluate to 3. I don't know why my code prints 0.
#include<iostream>
#include<string>
using namespace std;
bool isQstr(string str);
int main()
{
string strn;
int numdQuotes = 0;
int total = numdQuotes/2;
cout <<"enter any str "<<endl;
getline(cin,strn);
cout<<isQstr(strn)<<endl;
int len = strn.length();
for (unsigned int i=0; i<len; i++) {
if(isQstr(strn) == true) {
numdQuotes++;
}
}
cout<<"Total number of double quotes is "<<total<<endl;
return 0;
}
bool isQstr(string str){
int len = str.length();
for (unsigned int i=0;i<len;i++){
if(str.at(i)=='"')
return true;
}
return false;
}