Whenever I input a variable using cin
, after one hits enter it automatically goes to a new line. I'm curious if there's a way to use cin
without having it go to a new line. I'm wanting to cin
and cout
multiple things on the same line in the command prompt. Is this possible?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- How to show location of errors, references to memb
- Warning : HTML 1300 Navigation occured?
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- How to track MongoDB requests from a console appli
As others have noted, you can't do this with
cin
, but you could do it withgetchar()
. What you would have to do is:getchar()
(adding each to the end of astring
as it is read in, for instance), then' '
characters in the input, if you're reading inint
ordouble
values), thenint
,double
, etc.), thenHandling errors robustly would be complicated so I haven't written any code for this, but you can see the approach that you could use.