Lex Program to Check String Palindrome
This is the lex program to check whether the given string is palindrome or not.
%{
#include<stdio.h>
char num,temp[100];
int rev=0;
char arr[100];
%}
%%
. scanf("%s",arr); temp=arr; while(temp!=0){rev=rev*10+(temp%10); temp/=10;} if(rev==num) printf("PALI"); else printf("NO"); clear();
%%
clear(){rev=0;}
main(){yylex();}
Programs is working fine but how to do the same using file handling