title: Determining color based on user input
body: <p>I'm working on a parser for my raytracer in C that reads user input (to describe a scene). I want the user to be able to write in a color in this format:</p>
  
  <pre><code>sphere:
  {
   position: 0, 0, 0
   radius: 1
   color: white
  }
  </code></pre>
  
  <p>I want to give the user many options. In the past, for colors in other projects, I used a large header file with defines for colors in hexadecimal format like this:</p>
  
  <pre><code># define BLACK 0x000000
  ...
  </code></pre>
  
  <p>But i can't quite iterate through my defines and compare to user input ...
  <strong>What is the most practical way to read the user input and determine what color the user gave?</strong> Remember, I have dozens and dozens of colors and i want to be able to add new ones easily. I kinda want to avoid doing this for every color:</p>
  
  <pre><code>if (!strcmp(user_input, "red"))
      return (0xFF0000);
  if ...
  </code></pre>
  
  <p>But could there be a practical way of doing this in a loop with a predefined table of colors and values?</p>