1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

suggestion for correction

Discussion in 'C' started by rohit83.ken, Oct 20, 2007.

Thread Status:
Not open for further replies.
  1. rohit83.ken

    rohit83.ken New Member

    Joined:
    Oct 19, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    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 a moderator: Oct 20, 2007
  2. Mukul.Mangla

    Mukul.Mangla New Member

    Joined:
    Oct 20, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hiiiiiiiiiiii
     
  3. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    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.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,293
    Likes Received:
    365
    Trophy Points:
    83
    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
     
Thread Status:
Not open for further replies.

Share This Page