Write a SAL program in text file and generate SYMTAB and LITTAB

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
FILE *f;
char ch;
int line=0,word=0;
clrscr();
f=fopen("student","w+");
printf("Enter text press ctrol+z to quit\n");
do
{
ch=getchar();
putc(ch,f);
}
while(ch!=EOF);
 
printf("Total byts of files =%d ",ftell(f));
rewind(f);
while((ch=getc(f))!=EOF)
{
if(ch=='\n')
line++;
if(isspace(ch)||ch=='\t'||ch=='\n')
word++;
putchar(ch);
}
fclose(f);
printf("\n no of line=%d\n",line);
printf("no of word=%d\n",word);
getch();
}

Comments

  1. https://mohit9414.blogspot.com/?m=1



    Hello ....I have uploaded my practice codes of HTML, CSS, C, C++ and DSA language on my blogger. Kindly visit and do share it to your programmer friends and many..keep support. Thank you

    ReplyDelete

Post a Comment

Popular posts from this blog

Write a program to remove the Left Recursion from a given grammar.

Write a program to implement the lexical analyzer.