title: Using lex to detect floating point numbers
body: <p>I am trying to use lex to detect a floating point number.
  The following code with input +4.23e-21
  gives output</p>
  
  <p>{+4.23}e-21</p>
  
  <p>1</p>
  
  <p>I want it to print </p>
  
  <p>{+4.23e-21}</p>
  
  <p>1</p>
  
  <p>What am I doing wrong and how do I fix it?</p>
  
  <pre><code>%{
  #include &lt;stdio.h&gt;
  
  int N_count = 0;
  %}
  
  Sign [+-]
  
  Num [0-9]
  
  Expo [eE]{Sign}?{Num}+
  
  F {Sign}?({Num}*\.{Num}+)(Expo)?
  %%
  {F} {printf("Float = {%s}\n", yytext); N_count++;}
  
  %%
  
  int main()
  {
  
      yyin = fopen("test.txt", "r");
      yylex();
      printf("%d\n", N_count);
      return 0;
  
  }
  </code></pre>