Hey all, I tried to revise myself of using the while function but keep on getting errors whichever way i try, it's probbably something really simple i'm missing but been trying to find it for hours and failed. I've tried doing it as a while do, do while etc but keep getting certain errors.
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main()
{
string convert;
while (convert = "y")
{
float celsius;
float fahrenheit;
cout << " Welcome to the Celsius to Fahrenheit converter\n";
cout << " Please enter the temperature in celsius\n";
cin >> celsius;
fahrenheit = (celsius * 9) / 5 + 32;
cout << " The temperature in Fahrenheit is "<< fahrenheit <<" \n";
cout << " Do you want to convert again? [y/n]";
cin >> convert;
}
return 0;
}
This is the error i get with the way i've done it above:
error: could not convert 'convert.std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const char*)"y"))' to 'bool'|