I am trying to make a program that takes a scrambled word and checks it against a list of possible words. I am having trouble wusing the strlen function. Here's my code:
My errors say:Code:#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <fstream>
#include <iostream>
using namespace std;
bool check(string, string);
int main()
{
string scrambled;
string PossibleWord [13]={"will", "check", "it", "against", "list", "and", "return", "hello", "True", "or", "False", "Swap"};
cout << "Please enter scrambled word: ";
cin >> scrambled;
for (int i=0;i<sizeof(PossibleWord[i]);i++)
{
if (scrambled.size()==PossibleWord[i].size())
{
if(check(PossibleWord[i], scrambled))
{
cout<< "the word is " << PossibleWord[i]<<endl;
}
else
cout<< "the word is not found"<<endl;
}
}
system ("pause");
}
bool check(string p, string s)
{
bool match;
int count=0;
int psize, ssize;
psize=strlen(p);
ssize= strlen(s);
cout << "Size of p "<< psize <<endl;
cout <<"Size of s "<< ssize <<endl;
for (int i=0; i< psize; i++)
{
for (int y=0; y< ssize; y++)
{
if (p[i]==s[y])
{
cout << "Match with possible's "<< p[i] << " and scrambled's " << s[y]<< endl;
++count;
}
}
}
cout << "Count is "<< count <<endl;
if (count==psize)
{
match=true;
}
else
match=false;
return match;
}
no matching function for call to `strlen(std::string&)'
candidates are: size_t strlen(const char*)
My code is exactly like that of the book I'm using. Can someone please tell me what is wrong?