C++ ISO C&x2B+;禁止在C+中比较指针和整数[-fppermissive]+;代码

C++ ISO C&x2B+;禁止在C+中比较指针和整数[-fppermissive]+;代码,c++,pointers,C++,Pointers,我的代码有问题。它总是返回一个错误,ISO C++禁止指针和整数之间的比较[fPield]。你能帮我看看这里的问题是什么以及如何解决吗 #include <iostream> using namespace std; char x; int main() { cout << "Welcome to the citation machine. What do you want to cite?" << endl; cin >> x;

我的代码有问题。它总是返回一个错误,ISO C++禁止指针和整数之间的比较[fPield]。你能帮我看看这里的问题是什么以及如何解决吗

#include <iostream>
using namespace std;
char x;
int main()
{
    cout << "Welcome to the citation machine. What do you want to cite?" << endl;
    cin >> x;
    if (x == "book")
    {
        cout << "What is the name of the book?";
    }
}
#包括
使用名称空间std;
字符x;
int main()
{
cout x;
如果(x==“账簿”)
{

您不能将字符与字符串进行比较,您想做什么?错误消息是正确的,并告诉您问题所在。您正在比较
字符
(x)使用字符数组时,该字符数组会衰减为指针,这是您的问题。为了帮助人们回答您的问题,您需要更具体地说明错误。请在您的帖子中加入准确的错误文本(最好使用复制+粘贴以避免转录错误)。即使字符是8位每字符系统中的有符号字符,如果该系统不使用2个补码,则有符号字符可能不在范围[-128127]内。我已更新了我的帖子。这是额外的信息,对于理解错误消息来说并不是真的必要,但嘿,我是一个慷慨的人。谢谢。
#include <iostream>
using namespace std;
string x;
int main()
{
    cout << "Welcome to the citation machine. What do you want to cite?" << endl;
    cin >> x;
    if (x == "book")
    {
        cout << "What is the name of the book?";
    }
}