I want to ask user to input two parameters of one product and I want both of them to go on the same line. However, I also want to have some text between the values that user inputs.

So, I want to have something like this:

1) Initial text: "Oil quality "
2) User inputs value (say 5): "Oil quality 5"
3) User presses "return" and another portion of the text appears: "Oil quality 5 for $"
4) User inputs price value and after he/she presses "return" cursor moves to the next line.

I have a problem on step 3 as I have no idea which input command to use in order to both read the input after "return" is pressed and prevent the cursor from moving to the next line.

Any suggestions?

Recommended Answers

All 7 Replies

I'm guessing that the only way you could do this would be to use the windows api and or pdcurses library and move the cursor around as you please...which is not going to be as simple as you are hoping. I guessed if you are using managed C++ then it could be a bit easy as you will be able to use gotoxy(), but either way it isn't portable.

Chris

:( Looks like it will be easier to invent another UI..

P.S. Just in case someone will be willing to suggest some particular OS specific solution: I am using Mac

:( Looks like it will be easier to invent another UI..

P.S. Just in case someone will be willing to suggest some particular OS specific solution: I am using Mac

Thats why a GUI was invented....i could of gave you a windows specific solution easy enough...and probably found a linux solution but mac just makes it some what harder since i don't see as many people wanting to do it on mac. You would have to find a library that is compatiable with mac....im not sure if pdcurses and curses libraries are compatably with it. I guess it quite possible since if i am correct they are based around the same technology.

Chris

I do it on Mac all the time! All the way back in 1984 I used it, it was very nice! It had buttons and textboxes etc. other people used 640K DOS or something like it. Now Mac has something which is called Objective C to program in and is (imho) VERY ugly.
Still have a Mac with Vista installed (using Boot Camp).
The best off both worlds?

Try using :

cout<<"\b";

after user presses enter.

As far as i am aware the \b doesn't work for linefeeds...

Chris

I thought this was a slash b joke at first. :D

After getline(cin, string); it did nothing, after cin >> string; it crashed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.