title: Why is the program not returning YYText() or YYLeng()?
body: <p>I am attempting to create a lexical analyzer that will return the length of a token in a text file. </p>
  
  <p>I have a text file with a single letter 'a' in it. </p>
  
  <p>The following is my lex.l file </p>
  
  <pre><code>%option noyywrap 
  %{
  %}
  
  /* regular definitions */
  delim           [ \t\n]
  ws              {delim}+
  letter          [A-Za-z]
  digit           [0-9]
  
  %%
  
  {ws}            {/* no action */}
  letter          {return 1;}
  
  %%
  </code></pre>
  
  <p>The following is the main program file that uses the YYText() and YYLeng() function. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include "lex.yy.cc"
  
  using namespace std;
  
  int OpenInputOutput(int argc, char *argv[], ifstream &amp; lexerFIn, ofstream &amp; lexerFOut)
  {
  // open input
  if (argc &gt; 1) {
      lexerFIn.open(argv[1]);
      if (lexerFIn.fail()) {
          cerr &lt;&lt; "Input file cannot be opened\n";
          return 0;
          }
      }
  else {
  cerr &lt;&lt; "Input file not specified\n";
  return 0;
  }
  
  // open output
  lexerFOut.open("Output.txt");
  if (lexerFOut.fail()) {
      cerr &lt;&lt; "Output file cannot be opened\n";
      return 0;
  }
  }
  
  int main(int argc, char *argv[]) 
  {
  yyFlexLexer lexer; 
  while (lexer.yylex() != 0) {
      cout &lt;&lt; lexer.YYText() &lt;&lt; endl;
      cout &lt;&lt; lexer.YYLeng() &lt;&lt; endl;
  }
  return 0; 
  } 
  </code></pre>
  
  <p>When I run the program with the aforementioned text file, with the command ./a "sample.txt", it writes 'a' on a file. Why doesn't it cout YYText() or YYLeng() or write the length of the character in the output file?</p>