且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

控制台应用程序输入帮助

更新时间:2023-02-08 17:47:52

此[ ^ ]应该回答您的问题.提示:问题是
This [^] should answer your question. Hint: The problem is
cin >> Port;


>>运算符与getline()调用混合使用不是一个好主意.它们可以被认为是不兼容的,原因是...一个读取直到到达换行符(或回车),而另一个在读取内容后无法从流中删除换行符.

我确定您可以根据自己的错误弄清楚该做什么.
It''s not a good idea to mix the >> operator with getline() calls. They can be considered incompatible, reason being... one reads until the newline character is reached (or carriage return) and the other fails to remove the newline character from a stream after it has just read something.

I''m sure you can figure out which does what based on your bug.


在端口输入后添加行:

Adding lines after port input:

cin.clear();
cin.ignore(1000,'\n');



解决了我的问题



resolved my issue