suggestion for correction

Light Poster
20Oct2007,17:21   #1
rohit83.ken's Avatar
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
Newbie Member
20Oct2007,19:20   #2
Mukul.Mangla's Avatar
hiiiiiiiiiiii
Team Leader
20Oct2007,19:23   #3
DaWei's Avatar
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.
Go4Expert Founder
20Oct2007,19:58   #4
shabbir's Avatar
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