gpt4 book ai didi

C++ Binary >> 没有找到采用右手操作数类型的 const char 错误的运算符

转载 作者:行者123 更新时间:2023-11-28 05:05:33 25 4
gpt4 key购买 nike

我正在尝试学习 C++,但无法找出此错误的原因,它似乎与我其他未出现任何错误的 cout 行相匹配

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
int number = 42;
int guess;
bool notguessed = true;
while (notguessed);

cout << "Guess my number";
cin >> "Guess";
if (guess == number)
{
cout << "You got it" << endl;
notguessed = false;
}
if (guess < number)
{
cout << "To low try again" << endl;
}
if (guess > number)
{
cout << "To high try again" << endl;
}


return 0;
}

最佳答案

试试这个代码:-

# your code goes here
#include <iostream>
using namespace std;

int main()
{
int number = 42;
int guess;
bool notguessed = true;
cout << "Guess my number";
while (notguessed)
{
cin >> guess;
if (guess == number)
{
cout << "You got it" << endl;
notguessed = false;
}
if (guess < number)
{
cout << "To low try again" << endl;
}
if (guess > number)
{
cout << "To high try again" << endl;
}
}
return 0;
}

您正在尝试输入字符串“Guess”。将其更改为 cin>>guess。并更改 while 循环分号。

关于C++ Binary >> 没有找到采用右手操作数类型的 const char 错误的运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44911370/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com