Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;错误:警告:多字符字符常量/atof用法_C++ - Fatal编程技术网

C++ C++;错误:警告:多字符字符常量/atof用法

C++ C++;错误:警告:多字符字符常量/atof用法,c++,C++,C++新手。有人能给我解释一下我收到的错误信息是什么意思或者为什么我会收到它们吗?多谢各位 #include <iostream> #include <string> int main () { std::string

C++新手。有人能给我解释一下我收到的错误信息是什么意思或者为什么我会收到它们吗?多谢各位

#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'
#包括
#包括
int main(){
std::字符串输入;
双f,k;
/*编辑:进入do while循环的代码*/
std::cout使用:

“退出”
给出“警告:多字符常量”


您需要使用“
”将其与字符串文字进行比较。
'a'
是一个字符常量。
'exit'
也是一个字符常量;形式上,它是一个多字符字符常量。这里要使用的是
'exit'
,它是字符串文字。

在该语句中应使用字符串文字而不是字符文字

}while(input != 'exit');
这是应该的

}while(input != "exit");

input!=“exit”
应该是
input!=“exit”
。注意引号。
}while(input != "exit");