I've been trying to write this program and so far this is the best I could come up with. It doesn't work though.
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp,*fp1;
int i=0;
char str[80],fname[]="a1.txt",fname1[]="a2.txt";
clrscr();
fp=fopen(fname,"r");
fp1=fopen(fname1,"w");
if(fp==NULL)
{
printf("\n Cannot Open File : %s",fname);
getch();
exit(1);
}
printf("\n File Data : \n");
while(!feof(fp))
{
fgets(str,80,fp);
// printf("%s",str);
// fputs(str,fp1);
if(strstr(str,"//"))
{
while(str[i]!='\0')
{
if(str[i]!='/'&&str[i+1]!='/')
{
putc(str[i],fp1);
i++;
}
else
{
putc('\0',fp);
i++;
break;
}
}
}
else
{
fputs(str,fp1);
}
}
fclose(fp);
fclose(fp1);