gpt4 book ai didi

c++ - C++ 中多字输入的变量

转载 作者:行者123 更新时间:2023-11-28 03:19:07 24 4
gpt4 key购买 nike

我正在用 C++(命令行工具格式)编写一个冒险游戏,我无法确定是使用字符变量还是字符串变量来进行多词输入。我的代码看起来像这样:

if(directionOne=="go to lake"){cout<<"You are at the lake."}

directionOne 是我想知道的变量。当我使用 char 或 string 时,它只是在我完成后关闭程序。

最佳答案

声明为std::string:

std::string directionOne;

关于c++ - C++ 中多字输入的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15981188/

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