I'm new at programming and I got to do this for homework at school. So my problem is when I go into the console, I want my program to loop if I enter "oui" as x. The problem is that if I enter "oui", the program keeps looping alone for eternity and it doesn't let me enter new value.
x is bool. It accepts only 1 and 0 (or true and false if boolalpha is on)
You can: change locale and set boolalpha so it would accept oui / non as valid boolean values, or just make x a string and compare strings:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include<iostream>
#include<string>
#include<cctype>
int main()
{
std::string x;
do {
std::cout << "Entrer la température en Fahrenheit:\n";
double F;
std::cin >> F;
double C = ((F - 32) * 5) / 9; /*Formule pour calculer en Celsius*/
std::cout << "La température en celsius est:\n" << C << " degrés Celsius\n\n""Voulez-vous continuer? oui / non\n";
std::cin >> x;
for(auto& c: x)
c = std::tolower(c);
} while (x == "oui");
}
Edit: example of using locales to make input accept alternative spellings of true and false: