1

I have an odd situation ive made a login system that has many printf and color statements

______________________________________________________________
example        border_red(); printf (" $$   ");  
_____________________________________________________________

I have multiple printf statements in the menu and in the middle of my code I have a scanf statment to scan the username. The menu gets cut off halfway through making just the top part of the menu appear.

WHAT THE MENU IS SUPPOST TO LOOK LIKE

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            username:type here               $
$                                             $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

WHAT THE MENU LOOKS LIKE

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            username: type here 

i need the entire menu to show when you type in your username

QUESTION: How would i go about printing letters after a scanf statement

char username[50];
printf("#############################");
pritnf("#       username:");
scanf(log, & username);
printf(#                            #');
printf("#############################");

how would i go about not having the scanf statement cut off my menu

Sorry if this is a simple question I may have googled it wrong but ive been at this for 1 hour now and this is the only thing I can turn to.

1 Answers1

0

Both scanf and printf assume line-oriented input and output (think of a hardcopy terminal or teletype). They're just not designed to print a border, then scan from a location within that border1.

If you want to set up borders or place input fields in arbitrary places on screen, you'll have to look beyond the standard C library and use a third-party tool like ncurses.


  1. There are tricks you can use - you can send ANSI terminal escape sequences to place the cursor at arbitrary locations on the screen, but it's ugly and a lot of work. You're better off using a library like ncurses.

John Bode
  • 119,563
  • 19
  • 122
  • 198