Docstoc

PROGRAM TO GENERATE ABBREVIATED FORM OF A GIVEN FULL FORM |c++ PROGRAMS

Document Sample
PROGRAM TO GENERATE ABBREVIATED FORM OF A GIVEN FULL FORM |c++ PROGRAMS Powered By Docstoc
					//program to show the abbreviated form of the given full forms
/*Program written by: Mr. Biswajit Dey, Teacher (Computer Sc.),-
 Amrita Vidyalayam, Durgapur */
/*IMPORTANT: - THIS IS A TEXT FILE SAVE AS .CPP FILE AND PASTE IT IN THE
FOLDER - TURBOC3/TC/TCWIN45 ETC.
WHICH EVER EXISTS. AND ALSO CREATE A TEXT FILE IN THE SAME FOLDER WITH
NAME articles.txt and
write one article in each line example-

and
for
by
the
of
NOW RUN C++ IDE, SELECT THE FILE FROM THE FOLDER AND OPEN IT, COMPILE AND
RUN*/
//-----------------------------------------------------------------------
---------------

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>

int i,j,k,p,q,c,ac;
char input[100];
char temp[100];
char str[200];
char output[100];

void main()
{   clrscr();
      ac=c=k=0;
      int flag=0;
      int fc=0;
      FILE *fp;
      cout<<"\n Enter your Full Form: ";
      gets(input);

  k=0;
      q=k;
             for(j=k;j<=strlen(input)-1;j++)
             {
                   if(isspace(input[j])|| j==strlen(input)-1)
                   {
                         for(p=q;p<=j-1;p++)
                         {
                         temp[c]=input[p]; c++;
                         }
                         temp[c]='\0' ;
                         q=j+1;
        fp = fopen("articles.txt", "r");
          if(!fp)
          {
               cout<<"\a\n Database doesn't exsist....";
               exit(1);
          }
    while(fgets(str,sizeof(str),fp) != NULL)
        {
               // strip trailing '\n' if it exists
               int len = strlen(str)-1;
               if(str[len] == '\n')
                     str[len] = '\0';
                     if (strcmpi(temp,str)==0)
                     {
                       flag = 1;
                       break;
                     }
                     else
                     flag=0;


       }
       fclose(fp);
                         if(flag==0)
                         {
                               output[ac]=temp[0];
                               ac++;
                               output[ac]='.';
                               ac++;
                               //cout<<temp[0]<<".";
                         }
                         c=0;
                     }

             }

       output[ac]='\0';
       cout<<"\n ABBREVIATED FORM: ";
       cout<<strupr(output);
}

				
DOCUMENT INFO
Shared By:
Stats:
views:150
posted:10/31/2010
language:English
pages:2
Description: This is a C++ program which will generate an abbreviated form of the given Full Form. All the instructuions on how to run the program is given in the file itself. Read the comment section of the program