In a graphics program, you need to define colors where each color can be represented as either a name or an RGB triplet. How would you efficiently represent this in C?

  • Using a function
  • Using a structure
  • Using a union
  • Using an enum
In C, a union would efficiently represent colors that can be either a name or an RGB triplet because it allows sharing the same memory location for different data types. Enums, structures, and functions are not suitable for this purpose.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *