对于此代码:
#include <iostream>
#include <string>
#include <conio.h>
int main()
{
std::string a;
char c{};
while (c != '\r')
{
c = getch();
a += c;
}
a += "xyz";
std::cout << a;
}
输入:
12345
,然后Enter键
输出:
xyz45
我该如何阻止这种情况发生?
期望的输出:
12345xyz