#include <iostream>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cmath>
usingnamespace std;
int main()
{
{
srand(time(0));
int x = 1+(rand()%5);
switch(x) {
case 1:
cout << "Hello!" << endl;
break;
case 2: {
cout << "What's your name?" << endl;
string y;
cin >> y;
cout << y << " is a stupid name!" << endl;
}
break;
case 3:
cout << "You're a loser" << endl;
break;
case 4:
cout << "I like pie" << endl;
break;
case 5:
cout << "I like so muche MORE pie then you can imagine" << endl;
break;
default:
cout << ".....";
}
}
}
OKay, I fixed that now, and I added a cin.get(); to the end, and put everything in a while loop, but now it's still just looping even though I have the cin.get();
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cmath>
usingnamespace std;
int main()
{
{
while (true) {
srand(time(0));
int x = 1+(rand()%5);
switch(x) {
case 1:
cout << "Hello!" << endl;
break;
case 2: {
cout << "What's your name?" << endl;
string y;
cin >> y;
cout << y << " is a stupid name!" << endl;
}
break;
case 3:
cout << "You're a loser" << endl;
break;
case 4:
cout << "I like pie" << endl;
break;
case 5:
cout << "I like so muche MORE pie then you can imagine" << endl;
break;
default:
cout << ".....";
cin.get();
}
}
}
}