Skip to main content

How to tokenize a Pascal Program through file open

#include <conio.h>
#include <ctype.h>
#include <stdio.h>
#include <dos.h>
#include <Process.h>
#include <Stdlib.h>
#include <io.h>
#include <string.h>

void main ()
{
FILE *fs, *ft;
char ch, cha;
//char st[250];
char charray[50000];
clrscr();
int i;
i=0;

//WELCOME MESSAGE
    printf ("This program will tokenize a Pascal program\n");
        //READING A FILE

    if(access("MYFILE.TXT",0)==0)
    {

        fs = fopen("MYFILE.TXT","r");
            if (fs == NULL)
                {
                    puts ("Cannot open source file");
                    getch();
                    exit(0);
                }
        ft = fopen ("YOURFILE.TXT", "w" );
            if (ft == NULL)
                {
                    puts ("Cannot open target file");
                    fclose ( fs );
                    getch();
                    exit(0);
                }
        while ( 1 )
                {
                        ch = fgetc ( fs );
                        if ( ch == EOF )
                        break;
                        else
                        if(isspace(ch)||ch=='`'||ch=='~'||ch=='!'||ch=='@'||ch=='#'||ch=='$'||ch=='%'||ch=='^'||ch=='&'||ch=='*'||ch=='('||ch==')'||ch=='-'||ch=='_'||ch=='='||ch=='+'||ch=='\n'||ch=='\\'||ch=='|'||ch==']'||ch=='}'||ch=='['||ch=='{'||ch=='\''||ch=='\"'||ch=='\;'||ch=='\:'||ch=='?'||ch=='\/'||ch=='\.'||ch=='>'||ch==','||ch=='<'||ch=='\"'||ch=='\t')
                        {
                        putc ( ch, ft );
                        charray[i]= ch;
                        printf("%c\n",charray[i]);
                        }
                        else
                        {
                        putc ( ch, ft );
                        charray[i]= ch;
                        printf("%c",charray[i]);
                        }
                i++;
                }
        fclose ( fs );
        i--;
        fprintf(ft, "\nTotal Characters: %d", i);
        fclose (ft);
        }
    else
    {
    printf("Not allowed");
    }
getch();
}

Comments

Popular posts from this blog

Free Download Microsoft Macro Assembler (MASM 6.11)

Author :   Microsoft Email   :    None Website:    http://www.microsoft.com/ Released:    Sep 28 1993 Platform:    DOS Windows Source:      No Binaries:      Yes Summary       MASM 6.11 was the last stand-alone version of MASM available from Microsoft. Newer versions can be found "hidden" within other Microsoft products if you look hard enough. The download below includes the original install disks for MASM 6.11, along with patches to upgrade to 6.11d (last version that runs on DOS/Win16) and 6.14 (includes support for the Intel Pentium Pro processor, the Intel MMX architecture, AMD 3D Technology, and Intel Internet Streaming SIMD Extensions). Also included are the user's manuals in both Word and PDF format. Note: MASM is no longer sold by Microsoft, and the MASM executable and linker can be found in other tools available for free directly from Micros...

Technology Is Changing

Technology Is Changing!

10 Best Operating Systems For Laptops And Computers In 2021

10 Best Operating Systems For Laptops And Computers In 2021 Today’s modern age is blessed with the miracle of technology. One of these miracles that have made our lives simpler, faster and more entertaining is the computers. Computers are a revolutionary invention that really changed the course of human civilization. It has evolved from bulky desktop boxes to more portable and convenient laptops and mobile phones. However, the fact which many seldom talk about is what makes these computers work the way they do. We are of course talking about the operating system aka OS. Without an operating system, a computer cannot simply function. What Is The Difference Between Server OS And Everyday OS? Understanding how to differentiate a server OS from an everyday one is vital to our discussion. The differences are very specific. An everyday OS will be able to run programs like MS Word, PowerPoint, Excel, etc. including running one of your favorite video games. It enables applications that make br...