C++ - Wait for user input but print the next line -


so making gui ascci, wait user input print last line of ascci border. of wait user input , print last ascci border line. there anyway fix this?

example of want:

login screen

======================================================          welcome bank beta 0.1         ------------------------          (1)login         (2)create account           user input here  ====================================================== 

example of getting:

======================================================          welcome bank beta 0.1         ------------------------          (1)login         (2)create account           user input here 

here's code:

void login () {     cout << "======================================================" << endl         << "\t\twelcome bank beta 0.1" << endl         << "\t\t------------------------" << endl << endl         << "\t\t (1)login" << endl         << "\t\t (2)create account" << endl << endl; } int main() {      int loginchoice;     login();     cin >> loginchoice;     cout << "======================================================" << endl;     _getch(); } 

since working on console based gui, suggest using sort of cursor movement functionality. save lot of time in alignment of "objects" too.

here code need move cursor both win , unix

#ifdef _win32      #include <windows.h>      void gotoxy(int x, int y)     {         coord p = { x, y };         setconsolecursorposition(getstdhandle(std_output_handle), p);     }      #else      #include <unistd.h>     #include <term.h>      void gotoxy(int x, int y)     {         int err;         if (!cur_term)         if (setupterm(null, stdout_fileno, &err) == err)             return;         putp(tparm(tigetstr("cup"), y, x, 0, 0, 0, 0, 0, 0, 0));     }  #endif  

you can remove either of them if don't need platform independence, having them both no harm. interesting part:

void login () {     cout << "======================================================" << "\n"     << "\t\twelcome bank beta 0.1" << "\n"     << "\t\t------------------------" << "\n\n"     << "\t\t (1)login" << "\n"     << "\t\t (2)create account" << "\n\n";     gotoxy(0, 7);     cout << "======================================================" << "\n";     gotoxy(0, 6);     cout << "\t\t"; } int main() {      int loginchoice;     login();     gotoxy(0,8);     cin >> loginchoice;     _getch(); } 

the writing , reading independent of each other , can mess around positions lot more easyer.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -