我的程序提示用户输入文件名,并使用getline将其放入我的字符串变量中。 getline不会将用户的输入存储到文件名中。为什么?getline(cin,str)不起作用
int main() {
string fileName;
cout << "==============================================================\n"
<< "| Welcome to the Automatic Maze Path Finder! |\n"
<< "=============================================================\n"
<< "\nEnter the name of the Maze configuration file: ";
getline(cin, fileName);
此外,当使用cout语句来测试它将输出放到当前命令行。 例如: user @ computer:〜$ //程序输出由于某种原因而出现在这里? 为什么这样做?
你想在哪里输出控制台? –
你怎么知道它没有存储到'filename'中?你有没有用调试器通过它? – MicroVirus
你会遇到这个问题吗? https://stackoverflow.com/questions/1744665/need-help-with-getline –