Please Help. strcmp not working?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* In this game, there will be a ninja.
He will kill the dark evil Ninja. He will go to
New York, L.A, or Sanfrisco to search for the evil Ninja.
When he goes to the correct one, he will battle the evil Ninja.
*/

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
    string sPlayAgain;
    string *pPlayAgain = &sPlayAgain;

    do
    {
    string sPlayAgain;
    string *pPlayAgain = &sPlayAgain;
    cout << "\nWould you like to play again? Please type Yes or No\n";
    cin >> sPlayAgain;
    }while(strcmp(*pPlayAgain,"Yes")==0);
    return 0;
}


It says strcmp was not declared?? But I added <string>.
Last edited on
Wait nevermind. I didn't add the <cstring>. But now I have a new problem. It says "cannot convert string to const char*" ???? Helpppp
Try this it will run in codeblocks IDE mingw compiler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <cstring>
#include <fstream>

using namespace std;

int main()
{
    char *sPlayAgain;
    //char *pPlayAgain ;//= &sPlayAgain;

    do
    {
    //string sPlayAgain;
    //string *pPlayAgain = &sPlayAgain;
    cout << "\nWould you like to play again? Please type Yes or No\n";
    cin >> sPlayAgain;
    //pPlayAgain = &sPlayAgain;
    }while(strcmp(sPlayAgain,"Yes")==0);
    return 0;
}
Thanks Dinesh! Oh yeah, I fixed it a while ago, I actually made two similar questions lol. But thanks :)
Topic archived. No new replies allowed.