Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   suggestion for correction (http://www.go4expert.com/forums/suggestion-for-correction-t6941/)

rohit83.ken 20Oct2007 17:21

suggestion for correction
 
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);
}


Mukul.Mangla 20Oct2007 19:20

Re: suggestion for correction
 
hiiiiiiiiiiii

DaWei 20Oct2007 19:23

Re: suggestion for correction
 
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 20Oct2007 19:58

Re: suggestion for correction
 
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


All times are GMT +5.5. The time now is 11:37.