I have successfully removed single and multi line comments from input.c file but there are empty lines being created in output.c file wherever the comments were in input.c file. How to remove them?
#include<stdio.h>
int main()
{
FILE *f1,*f2;
char c;
int i=0;
f1=fopen("input.c","r");
f2=fopen("output.c","w");
while((c=getc(f1))!=EOF)
{
if(c=='/')
{
if((c=getc(f1))=='*' )
{
do
{
c=getc(f1);
}while(c!='*');
c=getc(f1);
if(c=='/')
c=getc(f1);
}
else
{
if(c=='/')
{
do
{
c=getc(f1);
}while(c!=10);
}
}
}
fseek(f2,1,i++);
putc(c,f2);
}
fclose(f1);
fclose(f2);
return 0;
}