I understand your issue after reading this. First, you're not understanding how C++ works. The data types (int, char, string, float, etc.) determine the kind of information that a variable can store. Reading over your program, one of the first lines I come to is
int lol;
where you're creating a variable "lol" and defining it as type int. int variables can only accept whole numbers (within a specified range, but that's irrelevant to this discussion). After reading through your first cout statement, I notice you ask the user type "lol". There is nothing wrong with having them do this.
Your first issue, however, comes from the fact that "lol" is a string, or a character array, depending on how you want to look at it. For simplicity, let's just say string. The user types "lol" and you tell the program that you want to store that in the variable lol. Again not an issue, until we take a closer look. The variable lol was declared as an int and "lol" is a string...we have an issue. cin can not figure out how to handle this (which is why you get some really funky results).
Since I believe you're just learning, you have two options, you can ask the user to enter a number (probably 0 is easiest) to continue (which is the most logical thing to do) or you can change the data type of lol to a string (which is a smart thing to do, but means you have to learn a little bit more).
Since I see you have a more current version of a C++ compiler, here is the easiest way to change the variable lol to a string:
1 2 3 4
|
#include <string>
// skip a few lines
// change int lol; to:
string lol;
|
Now you can continue using your code like you originally wanted to. Be careful though, cin has delimiters of whitespace (read: if you ask the user to enter a string and they happen to input a space before they press Enter/Return you'll have some unexpected side effects again). A proper solution to this is to change your
cin >> lol;
to this
cin.getline(lol);
because getline uses just one default delimiter instead of all whitespaces, and that's the Enter/Return key.
I hope this has helped you understand your code a little better.
Happy Programming =)
Edit: As a more technical note, I believe the exact reason why your code was terminating was because upon entering the string "lol", it was handled as a character string. Each cin of lol would accept one character which 'l' would be the first, 'o' second, and 'l' for the third, and since there was a value left in the buffer (I believe part of the '\n') it skipped the cin.ignore portion.