Write a program to reverse a word in a given string that is present in an input file.
Enter input file = file.txt
Enter line = "Hello how are you?"
Which word to reverse = 2
Hello woh are you?
Note: Input file (file.txt) can contain few lines including "Hello how are you?" After reversing the word
Answers
Answer:
hey guys tell me 1 ans
who had reaveled their face till now .?
anybody so pls ans
CODE:-
/*Lex program to take input from file and
remove multiple spaces, newline and tab
and write output in a separate file*/
% {
/*Definition section */
%
}
/* Rule: whenever space, tab or
newline is encounterd, remove it*/
% %
[ \n\t]+ {fprintf(yyout, "");}
. { fprintf(yyout, "%s", yytext); }
% %
int yywrap(){}
// driver code
int main()
{
/* yyin and yyout as pointer
of File type */
extern FILE *yyin, *yyout;
/* yyin points to the file input.txt
and opens it in read mode*/
yyin = fopen("Input.txt", "r");
/* yyout points to the file output.txt
and opens it in write mode*/
yyout = fopen("Output.txt", "w");
yylex();
return 0;
}