Hey this is really basic and I don't see why I can't do it but hey. I want something that will read in input until a blank line is entered (ie return is pressed twice).
The idea is that if there is one blank line, "finish" is incremented. If another, it goes to 2 and the while loop ends. If anything else is entered, it should reset to 0.
Initially, I was trying to use getline but I don't think you can use two characters as thing that terminates it (ie getline(a, b, "2x \n in here)). Apart from that, it worked perfectly.
So any help would be appreciated.
Code:
string inputText = "";
int finish = 0;
char tempInput;
cout << "Type the text. To end, type a blank line.\n";
while (finish < 2) {
tempInput = getchar();
if (tempInput != '\n') {
finish = 0;
inputText = inputText + tempInput;
}
else //if (tempInput == '\n')
{
finish++;
}
}
Initially, I was trying to use getline but I don't think you can use two characters as thing that terminates it (ie getline(a, b, "2x \n in here)). Apart from that, it worked perfectly.
So any help would be appreciated.