suggestion for correction

rohit83.ken's Avatar, Join Date: Oct 2007
Light Poster
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
Mukul.Mangla's Avatar, Join Date: Oct 2007
Newbie Member
hiiiiiiiiiiii
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Mukul.Mangla, I am not deleting your posts, because I want the owner of the forum to see them and ban you. I am closing this thread, meanwhile.

To the OP: Read the "Before you make a query" thread and clean up your code by using the code tags. Then we'll think about helping you, even though you have posted all your questions on multiple forums.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by Mukul.Mangla
hiiiiiiiiiiii
I would officially warn you to stop those unwanted posts or your account could get banned.

rohit83.ken, you need not have a new thread for your solution to the problem and you can use your other thread - removing comments of type // and /*

Also it looks like you seem not getting from the other threads and you seem to be creating multiple threads for the same problem. I am warning you last time or your account could get banned.
problem in this code