【发布时间】:2016-08-09 10:09:46
【问题描述】:
我的代码有问题。它总是返回一个错误 ISO C++ 禁止指针和整数之间的比较[-fpermissive]。你能帮我看看这里有什么问题以及如何解决它吗?
#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?";
}
}
【问题讨论】:
-
你在比较一个字符和一个字符串,你想做什么?
-
错误信息是正确的,并告诉你问题是什么。
-
您正在将
char(x) 与 char 数组进行比较,该 char 数组被衰减为指针,这是您的问题。 -
为了帮助人们回答您的问题,您需要更具体地说明错误。请edit您的帖子包含确切的错误文本(最好使用复制+粘贴以避免转录错误)。