I created a program to append line numbers to the text file passed as an argument to the program. yyin is working fine, but yyout is not working i.e, contents are being read from the specified file, but nothing is being written to the output file instead the output is display to the console.
%option noyywrap
%{
#include<stdio.h>
int linenumber=0;
%}
%%
^(.*)\n printf("%4d\t%s",++linenumber,yytext);
%%
int main()
{
yyin=fopen("test.c","r");
yyout=fopen("result.txt","w");
yylex();
}