

The program I wrote should compile and run as is and it'll put everything on one line. It's all doable and there may be a way to do it without using the methods listed above, but I can't think of one right now.īut make sure you really need to do this.

Once you've done that, move the cursor to the original place and all of the unwanted spaces will correct themselves. Some type of redirection of stdin so it doesn't immediately echo to the screen. The best way to remove the issue is to click on the show/hide symbol, figure out where you're cursor moves to when pressing the return or enter key and then moving the section break down one.Here’s an example: print(Hello there, end ) The next print function will be on the same line. If you want to require the Enter key to be pressed between inputs, but don't want it echoes onto the screen, I imagine that you'd need something like: To print without a new line in Python 3 add an extra argument to your print function telling the program that you don’t want your next string to be on a new line. If that's all you care about, then the program I posted WILL work.īottom line, I think, is that if you use cin, it's going to echo whatever is typed to the screen. The main point of this is that i want my inputs all in one row. Then the program I posted definitely would not work for your needs. The program I posted, if it fits your needs, is the way to go, I think.ĥ (press enter) 1(press enter) 2(press enter) There's nothing that says that Enter needs to be entered between inputs unless you have a specific need for that. That is A standard way, not THE standard way. I'm to enter 3 numbers, standard way would be: You should be able to copy and paste my program verbatim and compile it without error using a compiler like g++. If you want to just have the user enter five numbers on a single line, separated by spaces, then hit Enter once: int num If each number is a single digit, that changes things considerably. I was going to write up a response, but since that was just a GUESS of what the OP wanted, I'm going to hold off on that.Īlso, please note whether you are using "number" and "digit" interchangeably. It seemed a fairly odd request and I was puzzling over it. Enter is a delimiter), yet the newline would not be echoed onto the screen. Each Enter separated the next number from the last number (i.e. I thought the OP wanted the user to enter five numbers on one line and hit Enter five times. MyrtleTurtle might have interpreted in correctly and I didn't. That is what the enter key does, after all.goes to a new line.

Also, if the instructor configured the test cases to observe whitespace, then according to the above example, the program should output a newline after Enter x: (and possibly after the 10, if the instructor's test. To the OP, you should clarify what exactly you are looking for. But the program itself doesn't output the 5 (or the newline following the 5, which occurs when the user types 5 and presses enter). I interpreted the OP's request differently.

(there is no newline after output on the last line due to using echo -n).Do you mean that you don't want to have to press enter after each (one character) number is entered? (there is no newline after output on the last line due to using echo -n). Further output to that line will then overwrite what was previously outputted there.Ĭonverting the script to a Unix text file will solve your issue: $ bash -x script.shĭos2unix: converting file script.sh to Unix format. Ctrl+Shift-Enter inserts new line afther that statement even if the statement is multiline. Unix text files don't have this, and when a Unix system is outputting such a character, it causes the cursor position to move to the very start of the line. Your script is a DOS text file, meaning it contains a carriage return character (often written \r) at the end of each and every line.
