title: Lex rule for C preprocessor directive
body: <p>I am writing a lex program to tokenize a <strong>C</strong> program. I've written the following rule to match a <strong>C</strong> preprocessor directive</p>
  
  <pre><code> #.*                             {printf("\n%s is a PREPROCESSOR DIRECTIVE",yytext);}
  </code></pre>
  
  <p>But when I use a file as an input to yyin, pre-processor directives in the file are matched by yytext displayed is empty</p>
  
  <p>e.g I get</p>
  
  <pre><code>is a PREPROCESSOR DIRECTIVE
  </code></pre>
  
  <p>There is no problem when <strong><em>yyin</em></strong> is <strong>stdin</strong> but this arises only when a file is input. Is there an alternate LEX rule?</p>