所以我和我的朋友正在尝试制作一个基于文本的视频游戏,我一直在研究如何降低编程。到目前为止,这是我们的 c++ 程序:
#include <iostream>
#include <stdio.h>
char Choice;
using namespace std;
int main()
{
printf("You wake up to darkness.\n");
printf("Confused and tired, you walk to the nearest house.\n");
printf("You notice it's abandoned. What do you do?\n");
printf("1. Walk Away.\n");
printf("2. Jump.\n");
printf("3. Open Door.\n");
printf("Choose wisely.\n");
cin >> Choice;
if(Choice=1)
{
printf("The House seems to have a gravital pull on you. How strange.\n");
}
else if(Choice=2)
{
printf("Having Fun?\n");
}
return 0;
}
但是当我构建并运行它时,它会显示所有内容,但所有答案都是 if(Choice=1) 答案。我的程序中是否缺少需要的东西或部分内容相互矛盾?