While Loop with string.

hi, I'm new to C++ but I do have some beginner's experience with Python. I originally made an application that takes a string and turns it into a "pig latin" string. I just started trying to make it work in C++ but quickly ran into a problem, I used a string for the While statement but when I try to change it it doesn't work and I can't exit the program.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
using namespace std;

int main ()
{
string vowels = "aeiou";
string new_word = "";
string pig_message = "";
string play_again = "Y";
while (play_again == "Y" or "y")
{ cout << "it worked!";
  cout << "Would you like to play again? (Y or N)";
  getline (cin, play_again);
  cout << play_again;
}
return 0;
}
Last edited on
If you want multiple conditions you must do it like this:

while(play_again == "Y" || play_again == "y")

Btw, you should use ||, &&, etc instead of or, and since it is what most people are used to seeing.
I can't believe that worked! You're a life saver!
No problem. ;)
The problem with developers that dabble with multiple programming languages is the tendency to get syntax mixed up when you cross over. This problem is amplified if say you are maintaining different programs written in different programming language as your full-time job. You need to acquire the skills and mind-set to do change very fast :P

I have not even talk about the different programming language features and quirks too!

The problem with developers that dabble with multiple programming languages is the tendency to get syntax mixed up when you cross over. This problem is amplified if say you are maintaining different programs written in different programming language as your full-time job. You need to acquire the skills and mind-set to do change very fast :P

I have not even talk about the different programming language features and quirks too!

Well I took a computer class last year and we learned some Python and I decided to pick programming back up but I found out that some platforms require C++ which seems to be somewhat more universal than Python even though I would say Python is the better language.
Topic archived. No new replies allowed.