Recently, I've been having a problem.
#include <stdio.h>
#include <stdlib.h>
void main()
{
system("color 1F");
}
This can be printed Windows, but not in the Linux. Why?
Recently, I've been having a problem.
#include <stdio.h>
#include <stdlib.h>
void main()
{
system("color 1F");
}
This can be printed Windows, but not in the Linux. Why?
Nothing to do with c, you're performing a system
call on a command that doesn't necessarily exist.
color
exists in the Windows shell, but doesn't on Linux. Your code is just not portable on Linux as-is.
Linux has its own way of doing it. You should check which OS you're running on and call the setterm
instead for instance if you detect Linux (or at compilation time), so you already have Windows & Linux covered.
As a portable alternative, standard ANSI escape sequences are also widely available on a lot of OSes (For Windows, you need Windows 10, though)