This question already has answers here:
Color text in terminal applications in UNIX [duplicate]
(4 answers)
Closed 8 years ago.
I am using a Solaris server in my engineering course. Running code through SecureCRT and the gcc compiler. A task we have is to have the user input a string, and for the program to reverse it. The input string needs to show up in red, and I do not know what code manipulates colors to screen.
See Image for input /output
I tried running the code from the first link below, and it didnt output in any colors. It still shows all of the words in the standard black and white
Look into ncurses. It's a library built to handle this sort of thing, among other formatting.
start_color() in curses might be a good start.
Related
This question already has answers here:
List of ANSI color escape sequences
(6 answers)
C color text in terminal applications in windows
(3 answers)
Closed last year.
I want to make a text in color in C. I tried using some method below but this does not seem work on all platforms and C versions.
printf("\033[1;31m");
printf("Hello World\n");
printf("\033[0m");
On Windows 10 this seems to work ok, but on other systems I get this printed as text such as ←[1;31m or nothing prints at all.
Is there a more standard way to color a text which is more universal accross Windows and Unix systems?
This question already has answers here:
console print w/o scrolling
(7 answers)
Closed 1 year ago.
I have a program that is a simulation, it updates constantly and writes messages in terminal, however, this causes the terminal to constantly scroll with new lines. I am wondering if there is a way to make terminal print lines and then clear after 10 seconds and then update?
Many terminals accept special escape codes allowing the programmer to move the cursor, set the colour and many more functions.
To use it good people wrote the ncurses library https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/
This question already has answers here:
Non blocking getch()
(2 answers)
Closed 3 years ago.
I am making a typing game in C Language in this game letters come from the top of the window and user has to type that letter to delete it and to stop it from touching the specific boundary line if it touches the boundary line user lose points and ultimately lose the game. Now I am having trouble to print the list of the characters and take input at the same time. If I tried to use the scanf() or getch() function they both stop the printing process is there any way that I could get input from a user without stopping the printing process.
Kbhit Function really Works for that problem.
This question already has an answer here:
Game in linux terminal: Changing images: printing over already printed text
(1 answer)
Closed 8 years ago.
Hey so I want to make a game like Snake or Dwarf Fortress in a console/terminal. I want to print a game field with *'s and other symbols and change them without moving to console upwards. How can I do this?
Use a library like ncurses. It is meant for building console-based UIs.
This question already has an answer here:
Determining if file has been copied or not in C [closed]
(1 answer)
Closed 9 years ago.
In Windows, if you go to a file's properties it shows the last access time right under the time last modified. This changes when I copy it.
How do I view this in C?
You can use the GetFileTime() function to get it. This MSDN article has more details about file times.
The portable way of getting the last modified timestamp is by using fstat or stat. If you want to go the Windows-only route (by directly calling a Windows API), see #xxbbcc's answer.
See How can I get a file's size in C++? for a short piece of sample code that uses stat/fstat - only change for your purpose is that you'll want to read the time_t st_mtime field.