I'm an amateur programmer learning how to use c++ in xcode, and I've been trying to create a program where you answer asked questions, and the questions are different depending on your answers. The thing is, I keep getting the error: Thread 1: EXC_BAD_ACCESS (code=1, address=0x0), and I have no idea what caused it. Here's my code currently:
#include <iostream>
#include <string>
using namespace std;
int main() {
string name;
cout << "what is your name ";
getline (std::cin, name);
string yes;
cout << "ok, " << name << ", do you want to play a game? ";
getline (std::cin, yes);
cout << "\nno " << std::endl;
string input =0;
cin >> input;
string Yes = "yes";
string No = "no";
if (input == No)
{
cout << "ok, sorry" << endl;
}
else if (input == Yes)
{
cout << " a question" << endl;
}
}