C++ newbie. Could someone please explain to me what error messages I received mean or why am I getting them? Thank you.
#include <iostream>
#include <string>
int main () {
std::string input;
double f, k;
/* edit: codes to go inside the do while loop */
std::cout << "\nEnter Fahrenheit temperature or 'exit' to end program: ";
std::getline(std::cin, input);
do {
f = std::atof(input.c_str()); //convert string input to double
k = (f + 459.67) * (5/9);
std::cout << "Entered Fahrenheit temperature is: " << f << std::endl;
std::cout << "Temperature in Kelvin is " << k << std::endl << std::endl;
}while(input != 'exit'); //program runs until input is 'exit'
return 0;
}
Errors:
t.cc:21:19: warning: multi-character character constant
t.cc: In function `int main()':
t.cc:21: error: no match for 'operator!=' in 'input != 1702390132'
EDIT: Thank you everyone for the advice on while(input != 'exit'). Could someone check that I'm using atof correctly in the calculation section? I'm not getting any calculation with what I have. If I enter 45, I get k = 0 instead or 250.