getline(cin, str) not working
getline(cin, str) not working
我的程序提示用户输入文件名,然后我使用getline将其放入字符串变量中。getline没有将用户的输入存储到文件名中。为什么?
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:~$//程序输出出于某种原因而出现在此处?它为什么这么做??
std::cin
表示标准用户输入,std::cout
表示标准输出。如果您希望将输入/输出从不同的内容中读取/写入,则必须使用该系统(例如std:fstream
)。
你的代码对我来说似乎很好。
相关文章:
- GDB - strcmp not working: __strcmp_sse2_unaligned
- QT qScriptConnect is not working
- QDesktopServices::openUrl() not working Qt
- C++ std::set ordering not working with customer class*
- C++ SetWindowText not working
- visual studio 2012 c++ hello world - iostream not working
- getGravity not working?
- Opencv findcontours CV_RETR_EXTERNAL not working
- c++ srand() not working
- std::queue::empty() not working?
- BCB swprintf not working
- 将类型作为指向另一个类的对象的指针的泛型类-NOT WORKING
- LoadLibrary is not working
- gluUnProject not working
- C++ catch bad_alloc not working
- updatelayeredwindow not working
- OpenMP set_num_threads() is not working
- glOrtho not working
- Cuda atomicInc not working
- WinAPI DestroyWindow not working