0
votes

Here is a sample run of this program, assuming that the executable file is called match and hit. This run illustrates a situation where the human player wins the game. User input is bolded.

/home/userXYZ/ECE15/Lab3> match_and_hit
Welcome to the MATCH and HIT game
The computer has selected a 4-digit number.
Try to deduce it in 12 rounds of queries.

Round #1
Please enter your query (4 digits): 5341 <---(this number should be underlined)

.......

I can't figure out how to underline the user input. Any help would be greatly appreciated.

3
Is this a CLI (Command Line Interface) application? - Richard J. Ross III
does your terminal support underlined text? or do you want - characters on the next row? - Karoly Horvath
i dono anything about CLI application. my professor asked me to make the user input underline - Nareg Rostami
Does your professor know curses? - wildplasser
i got it work thank u so much - Nareg Rostami

3 Answers

2
votes

Assuming your terminal supports ANSI escape sequences, you can use this:

#define ANSI_UNDERLINED_PRE  "\033[4m"
#define ANSI_UNDERLINED_POST "\033[0m"

printf(ANSI_UNDERLINED_PRE "underlined" ANSI_UNDERLINED_POST "\n");
0
votes

With a CLI Application, you cannot, that would be dependent on the actual terminal that is calling your application.

0
votes

If your terminal supports it:

printf("\x1b[04mUnderlined\x1b[24mUnderlineOff");