0
从here中摘录了示例。std :: cin.getline不等待输入
相关代码:
char line[chat_message::max_body_length + 1];
while (std::cin.getline(line, chat_message::max_body_length + 1))
{
chat_message msg;
msg.body_length(std::strlen(line));
std::memcpy(msg.body(), line, msg.body_length());
msg.encode_header();
c.write(msg);
}
c.close();
t.join();
的应用立即退出,而无需等待我把聊天消息中 我再没修改代码预期使用Windows,而不是一个控制台应用程序(我还在。附加控制台Alloc & AttachConsole)