Problem exiting While loop

I am writing a program for programming class. The program involves menus, and it runs just fine. I wanted to add a while loop to bring it back to the beginning if the user enters 'r' or 'R' to restart. The problem is that I cannot exit the loop, no matter what I input for x. I have tried quite a few things and this is the current code I am trying to run. I have tried changing the while statement to use ascii values for r and R, and have spent quite a while trying to do other things to get it to loop. Any help would be appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
using namespace std;

int main()
{
   char x= 'y';
   while ((x != 'r') || (x != 'R'))
   {

//my code is here
      cout << "Press r to restart or another key to exit";
      cin >> x;
   }
return 0;
}
Last edited on
A senior CS major happened to come by and helped, resolved
changed to

char x = 'r';
while ((x == 'r') || (x == 'R'))
{
cout << "Press r to restart or another key to exit";
cin >> x;
}
return 0;
}
Topic archived. No new replies allowed.