123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Simulating a preprocessor using files

--------------------------------------------------------------------------------

Description : This menu driven program is to open a file and doing the operation of a C preprocessor, like deleting the comments, including the header files etc and then finally to store the resultant progran in another file called.

#include<stdio.h>
#include<conio.h>
output()
{
FILE *fo;
char c;
fo=fopen("outputc.c","r");
clrscr();

printf("__________________________________________________________________
_______<BR>);
printf("
The output file.
<BR>);

printf("__________________________________________________________________
_______
<BR>);
do
{
c=getc(fo);
putchar(c);
}while(c!=EOF);

printf("
________________________________________________________________
__________<BR>);
fclose(fo);
getch();
}

comment()
{
FILE *fs,*fd;
char ch,c,fi[20];
// clrscr();
fflush(stdin);
printf("
Enter the file to be read:");
gets(fi);
fs=fopen(fi,"r");
fd=fopen("outputc.c","w+");
if((fd==NULL)||(fs==NULL))
{
printf("
Sorry, The input file does not exist.");
getch();
}
do
{
c=fgetc(fs);
if(c=='/')
{
if((c=fgetc(fs))=='*')
{
while(1)
{
if((c=fgetc(fs))=='*')
{
if((c=fgetc(fs))=='/')
{
ch=fgetc(fs);
c=fgetc(fs);
break;
}
}
}
}
}
{
putchar(c);
fputc(c,fd);
}
}while(c!=EOF);
fclose(fs);
fclose(fd);
return;
}
include()
{
FILE *fs,*fd,*ft;
char c,temp[50],name[50],ch,fin[10],*path;//,a[]="define";
int i=0,f;
// clrscr();
fflush(stdin);
printf("
Enter the file to be read:");
gets(fin);
fs=fopen(fin,"r");
fd=fopen("outputc.c","w+");
if((fd==NULL)||(fs==NULL))
{
printf("
Sorry, The input file does not exist.");
getch();
}
do
{
c=fgetc(fs);
if(c=='#')
{
while((c=fgetc(fs))!='
')
{
if(c=='<' || c=='"')
{
c=fgetc(fs);
do
{
temp[i]=c;
i++;
c=fgetc(fs);
}while(c!='>'&& c!='"');
}

}
temp[i]='
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG