title: C programming with getopt(): giving command line flags criteria
body: <p>I am beginning to teach myself C. I have run into a few bumps here and there but right now I am stumped by <code>getOpt()</code>. The main thing thats giving me trouble is when I try to make certain flags dependent on other flags. For example I want these to work: </p>
  
  <pre><code>./myfile -a -b -c blue
  </code></pre>
  
  <p>But none of the other options to work without -a. Thus <code>./myfile -b -c purple</code> would be invalid. Is it possible for getopt to handle this kind of "flag dependent" criteria? How would I go about doing that? Secondly, lets say that no matter which flags are passed, along with it must be a colour. </p>
  
  <p>So <code>./myfile -a -b green</code> and <code>./myfile red</code> are both valid. I understand that this all lies within the options parameter of getOpt() (which is currently set up to look something like this "abc"), but how would I make one parameter required for each instance without doing "a:b:c:" since this would not include the mandatory colour if no flags are passed. </p>