#include <iostream>
#include <fstream>
usingnamespace std;
int main () {
int x = 1, y=1,z=1;
ofstream myfile ("example.txt",ios::app);
if (myfile.is_open())
{
while (x=1)
{
cout << "Type what you want to store\n";
string entry1;
getline(cin,entry1);
myfile << entry1<< "\n\n";
cout <<"\n\nSuccessfully stored\n\n";
string response;
cout <<"Would you like to input more?(type yes or no)\n\n";
do
{
getline(cin,response);
if (response=="yes")
{
y=2;
}
elseif (response=="no")
{
y=2;
x=2;
}
else
cout << "Type yes or no exactly\n\n";
}while (y=1);
}
}
else cout << "Unable to open file";
return 0;
}
Might I suggest also that instead of using an int to keep track of something that is inherently true/false, you instead use the bool type, which takes values of true/false.
I also suggest that you don't use single letter variable names. y means nothing. You could have called it something meaningful like keep_looping