Is there a way to prevent a program from breaking to the next line after a cin << execution?
1 2 3 4 5 6 7 8 9 10
//Current Output
Guess 1: user input
: program output
Guess 2: user input
: program output
//Desired Output
Guess 1: user input : program output
Guess 2: user input : program output
are you sure of that? my professor was supposed to show my class but never got to it. apparently he made our program in java so we're having some difficulties...
In Java? Well I suppose it could be possible in Java, though I don't have much experience with console-type I/O there. Though a C/C++ forum isn't exactly the best place for a question about a Java assignment.
well we have to write it in c++ just when he went through the problem he was using java. are there ways to create an iostream segment that will debuffer the input stream? i feel like not forcing the program to break line should be simple... a professor had also mentioned '\c' or something as well
That...seems like a rather useless teaching method. If you're learning C++, why wouldn't you be taught in it?
Anyway, there are ways to do it. The first that comes to mind is using a library like curses to set up unbuffered input, which will read characters as they are typed so the user doesn't have to press enter. That's the main issue; if the user presses enter, you'll be moved to the next line. Unless you avoid that, or move the input cursor around again your output will be on a different line.
i need to avoid breaking the line after user presses enter. if i had the program read the input character by character i'd basically have to scrap this code