0
The program I am doing works as follows: Whenever an incorrect value is typed, I want the program to warn that the value is incorrect, and soon after clear only the error message so that the user can write another value, but the only instruction I know (system("cls")
) clears the screen completely. There is some instruction similar to system("cls")
in C, but cleaning only a certain part of the screen, and not the screen totally?
In fact,
system("cls")
is not guaranteed to clean the screen. What is the callsystem
, ofstdlib
? It is simply a delegation to the operating system to call an operating system command line. It turns out that the commandcls
on the Windows terminal causes the terminal to have the write prompt at the top. So it’s not something from C, but an external program you are calling. Just like thesystem("pause")
is calling the programpause
windows– Jefferson Quesado
@Jeffersonquesado I get it. Thanks for the clarification, but do you know any commands to clean only part of the screen? Or some command of C itself that does similar thing?
– GiovanePS
You would have to use functions from the conio. h library to manipulate the screen more elaborately in MS-DOS/Windows. In UNIX it would be the ncurses library.
– epx
Summarizing what Jeff meant, it is not possible to say that something will work, whether in C or outside it, depends on the system and back and forth of settings, but if it is something simple my suggestion would be to copy the "output" (which should be done before sending to the actual output), clear everything, pick up what was copied, manipulate and clean the desired area on its own and then play again, causing the impression that it was cleaned only part but was actually "redesigned". But it’s just a suggestion, it must have some g a m i b a r a lib that does something like this.
– Guilherme Nascimento
@epx, not short to
conio
, and also not many people liked https://answall.com/a/304271/64969– Jefferson Quesado
@Guilhermenascimento I managed to solve with the manipulation that you indicated, and some more gambiarras, but it worked. But I was able to solve it because the problem was at the beginning of the code, if it was in the middle or at the end it wouldn’t, so your tip helped me in parts. I needed some command that would really clean up just part of the code, without all these tricks of repeating all the code, so it looks like it just wiped out a part, which is I did here.
– GiovanePS