Q:

Array to control individual GPIO's

I'm new to embedded systems and C programming. I am Currently trying to program a PCB using an STM32 microcontroller to control an array of 8 fans upon receipt of a single command. i.e 00001011 will switch on fans 5, 7 and 8. There are a total of 256 possible combinations and it wouldn't be very efficient to program each individual one.
I am thinking of using an array to achieve this using something like;
fan_array[8] = {fan1, fan2, fan3, fan4, fan5, fan6, fan7, fan8};
printf ("Input fan state"); // user would input binary number as shown above
scanf (%d, fan_array);

Would this set the GPIO pins controlling each fan high or low according to the binary values input into the array?

A:

If you wire the fans up to the 8 bits of a GPIO port, you can write the byte value directly to the port, and each fan will respond to only its bit. No need for any fancy software.

