title: cant copy the yytext with strcpy
body: <p>This is my code</p>
  
  <p>strcpy doesnt copy the yytext</p>
  
  <p>Any suggestion why?</p>
  
  <p>These are my globals</p>
  
  <pre><code>char** v; /* array of variables and their values */
  int i;
  </code></pre>
  
  <p>some name definition</p>
  
  <pre><code>WORD    [a-zA-Z]
  DIGIT   [0-9]
  </code></pre>
  
  <p>These are the states</p>
  
  <pre><code>&lt;VAL&gt;"\"".+"\"" {int x=sizeof(yytext);
      v[i]=(char*)realloc(v, x*sizeof(char));
          strcpy(v[i],yytext);
      i++;
      BEGIN(INITIAL);}
  &lt;VAL&gt;.  { i--;printf("error");}
  &lt;SAVE_VAL&gt;{WORD}[{WORD}{DIGIT}_]*   { 
      if (NULL==v){
          v=(char**)realloc(v, 100*sizeof(char*));
          i=0;
      }
      int x=sizeof(yytext);
      v[i]=(char*)realloc(v, x+2);
      strcpy(v[i],yytext);
      i++;
      BEGIN(VAL);
      }
  
  val" " {BEGIN(SAVE_VAL);}
  </code></pre>
  
  <p>This is the yywrap</p>
  
  <pre><code>int yywrap(void){
      return 1;
  
  }
  </code></pre>
  
  <p>This is the main</p>
  
  <pre><code>int main(void) { 
  
      yyin=fopen("input.txt","r");   
      yylex();
      fclose(yyin); 
  </code></pre>
  
  <p>This is the loop to print the strings</p>
  
  <pre><code>    for (int j=0;j&lt;100;j++){
          if (NULL==v[j])
              break;
          printf("%s",v[j],i);
      }
  } 
  
  
  }
  </code></pre>
  
  <p>I'm tring to run it on 
      val a="asdasd";</p>
  
  <p>I'm expecting it to print
  <code>a</code>
  <code>asdasd</code></p>