I know this has been answered, but to address one of the questions you asked in comments:
"...Can this method apply to a multiple-assigning code? Since I have 12 colors, and I need to arrange them to 4-color combination based on
"if statement"...
I wanted to suggest an approach that has not yet been discussed.
If you know that you have 12 colors that need to be selected via logic in your code, you can use the following components to a simple executable to do what you are asking:
a single array of strings variable that contains 12 color strings,
an accompanying enum providing a human readable index to access colors in the array.
a variadic
function designed print a list of any number of any combination of color selections.
The following complete code example provides a simple illustration of using these 3 items in conjunction: (The code can be modified to accommodate using if/then/else or switch() statement selection criteria as needed.)
enum {
RED,
ORANGE,
YELLOW,
GREEN,
BLUE,
PURPLE,
BROWN,
MAGENTA,
TAN,
CYAN,
OLIVE,
MAROON,
MAX_COLOR
};
//constant character array of colors
const char color[MAX_COLOR][10] = {"Red","Orange","Yellow","Green","Blue","Purple","Brown","Magenta","Tan","Cyan","Olive","Maroon"};
//prototype
void print_color( int nHowMany, ... );
int main(void)
{
//your selection criteria code can precede this call to a variadic fucntion
//from which you can call any number of any combination of the enumerated
//values in the enum...
//argument 1 is number of colors, then enter colors to be printed
print_color(3, MAGENTA, OLIVE, YELLOW);
//However, if for your own reasons you still want to use discrete
//pointer variables, the string array can be used to initiate
//them as well:
const char *a = color[RED];
const char *b = color[ORANGE];
const char *c = color[YELLOW];
// ...
const char *l = color[MAROON]
return 0;
}
void print_color( int nHowMany, ... )
{
int color_index =0;
va_list intArgumentPointer;
va_start( intArgumentPointer, nHowMany );
printf("%d Colors Selected:\n", nHowMany);
for( int i = 0; i < nHowMany; i++ )
{
color_index = va_arg( intArgumentPointer, int );
printf("%d %s\n", i+1, color[color_index]) ;
}
va_end( intArgumentPointer );
}
The output from the above example:

char. Also, those strings aren't correctly null-terminated. Just putconst char brown[] = "Brown";instead.printf("color: %s %s\n",a,b);will print the strings instead of single characters.