Help with "While" errors

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdlib>
#include <iostream>
using namespace 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'|

Thanks for the help in advance
You made the easiest-to-fix mistake, you used assignment (=) instead of comparison (==). Also, make sure you assign "y" to the string before the loop!
Thanks a lot, i did try doing both of those fixes beforehand but i guess i never did both of them at the same time, works now :).
Topic archived. No new replies allowed.