the code is not working properly
its about removing comments

//Program to print a file by removing Comments
Code:
#include<stdio.h>
void main()
{
FILE *fp;
char ch;
//clrscr();
fp=fopen("temp.txt","r");
while(1)
{
ch=fgetc(fp);

if(ch==EOF)
break;
else
{
if(ch=='/'){
ch=fgetc(fp);
if(ch=='/') 
{
while(1)
{
ch=fgetc(fp);
if(ch=='\n')
goto label;
}
}
if(ch=='*')
{ 
while(1)
{
ch=fgetc(fp);
if(ch=='*')
{ 
ch=fgetc(fp);
if(ch=='/')
{
while(1)
{
ch=fgetc(fp);
goto label;
}
}
else printf("*");
}
}
}
else printf("/");
}
}
label:printf("%c",ch);
}
fclose(fp);
}

Last edited by shabbir; 20Oct2007 at 19:51.. Reason: Code block