how should i write or change the input code in c++ so that in the ouput screen there is no change of line. That is, even after encountering a "cin" statement and taking the respective input from the user and also after pressing enter the cursor remains in the same line . is there any way to do so? please help.
Asked
Active
Viewed 321 times
0
-
what about `cin >> a >>b`? – sjsam Dec 08 '15 at 07:41
-
Which OS are you using? I believe there is no portable way to do this. – wimh Dec 08 '15 at 07:45
-
yes cin>> a >> b would work voluntarily.you can enter both the values in the same line with / without spaces but on pressing enter once there is a new line jump. – soumya dubey Dec 08 '15 at 07:51
-
Generally speaking, you can't prevent `cin` from doing this (mostly because `cin` itself isn't doing it in the first place). The only real cure for the problem is to use some alternative to `cin`, such as `curses`. – Jerry Coffin Dec 08 '15 at 07:52
-
i am using windows 8.1 – soumya dubey Dec 08 '15 at 07:52
-
Possible duplicate of [Unechoed string input in C++](http://stackoverflow.com/questions/9292231/unechoed-string-input-in-c) – wimh Dec 08 '15 at 07:57
-
@jerry coffin i am not aware of the syntax of `curses`. is it the same as `cin` – soumya dubey Dec 08 '15 at 08:01
-
1@soumyadubey: No--`curses` is really a C library, so it uses normal C function calls with no operator overloading. – Jerry Coffin Dec 08 '15 at 08:04
-
@soumyadubey : I think jerry has hit the bullseye. Else there is no way to achieve what you're looking for. – sjsam Dec 08 '15 at 08:14
-
The only two realistic options are: (1) live with it, (2) start GUI programming. – Christian Hackl Dec 08 '15 at 11:11
-
thanks @Jerry Coffin. `curses.h` actually helped. – soumya dubey Dec 08 '15 at 13:39
1 Answers
1
The language and its standard library have no notion of screen or cursor.
What you want to do definitely depends on your architecture and operating system. On POSIX systems, disabling echo on the terminal may be a starting point.

Paulo1205
- 918
- 4
- 9