Would you like to add a parameter in: system ("color", var) in C language?

0

I'm creating a simple program to change the color of the system. Only, I want to give the user the option to write the color he wants. Ex: Has the table 1: Blue 2: Green F: Red C: Yellow

Being F background color and 1 font color. Then looking at the table, he would choose the colors, and I would store your choice in an opccor variable. With that, I tried to do it that way, but it did not work out. Does anyone have any idea how I can do it? Obg for attention.

/ * system ("color F1", opccor); * / . system ("color% c", opccor);

    
asked by anonymous 02.04.2017 / 04:27

1 answer

2

system() does not receive parameters, but you can use snprintf() to compose your string command:

char buf[20];
snprintf(buf, sizeof(buf), "color %s", opccor);
system(buf);
    
03.04.2017 / 22:25