printing - How to position the input text cursor in C? -



printing - How to position the input text cursor in C? -

here have simple program:

printf("enter number in box below\n"); scanf("%d",&number);

now, output this:

come in number in box below +-----------------+ | |*| | +-----------------+

where, |*| blinking cursor user types value.

since c linear code, won't print box art, inquire output, print top row , left column, after input print bottom row , right column.

so, question is, perchance print box first, have function take cursor box?

if under unix terminal (xterm, gnome-terminal ...), can utilize console codes:

#include <stdio.h> #define clear() printf("\033[h\033[j") #define gotoxy(x,y) printf("\033[%d;%dh", (x), (y)) int main(void) { int number; clear(); printf( "enter number in box below\n" "+-----------------+\n" "| |\n" "+-----------------+\n" ); gotoxy(3, 2); scanf("%d", &number); homecoming 0; }

and nice ascii fine art using box-drawing characters :p

printf( "enter number in box below\n" "╔═════════════════╗\n" "║ ║\n" "╚═════════════════╝\n" );

more info:

man console_codes

c printing output

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -