Re: non commented lines

Discussion in 'C Programming' started by Bertrand Mollinier Toublet, Jul 25, 2003.

  1. Ravi Uday wrote:
    > hi,
    > i have written a piece of code which removes all the comments in a
    > given 'C'/'C++' input source file and prints the total number of
    > non-commented lines. This doesnt seems to work if the input file is:
    >
    > #include<stdio.h>
    > int main() {/* main starts here
    > write code here*/int i;
    > }
    > Actual result is : Number of non commented lines is: 4
    > Result I got is: Number of non commented lines is: 3 !

    Look, I didn't look at the code, but it seems to me that in the example
    above, the right answer is indeed 3. It is all a matter of
    specification, though.

    Indeed, after removing the comment, all that's left is:

    #include <stdio.h>
    int main() {int i;
    }

    And that's three lines...
    Now of course, if your original code had been

    #include <stdio.h>
    int main() { /* main starts here */
    /* write code here */int i;
    }

    Then once stripped, you would have had

    #include <stdio.h>
    int main() {
    int i;
    }

    and should have expected 4 lines.
    --
    Bertrand Mollinier Toublet
    "No sea vivo, Buendia" -- El presidente del tribunal,
    in Cien anos de soledad, de Gabriel Garcia Marquez
    Bertrand Mollinier Toublet, Jul 25, 2003
    #1
    1. Advertising

  2. Bertrand Mollinier Toublet

    Ravi Uday Guest

    Bertrand Mollinier Toublet <> wrote in message news:<bfri1d$h6ku6$-berlin.de>...
    > Ravi Uday wrote:
    > > hi,
    > > i have written a piece of code which removes all the comments in a
    > > given 'C'/'C++' input source file and prints the total number of
    > > non-commented lines. This doesnt seems to work if the input file is:
    > >
    > > #include<stdio.h>
    > > int main() {/* main starts here
    > > write code here*/int i;
    > > }
    > > Actual result is : Number of non commented lines is: 4
    > > Result I got is: Number of non commented lines is: 3 !

    > Look, I didn't look at the code, but it seems to me that in the example
    > above, the right answer is indeed 3. It is all a matter of
    > specification, though.
    >
    > Indeed, after removing the comment, all that's left is:
    >
    > #include <stdio.h>
    > int main() {int i;
    > }
    >
    > And that's three lines...
    > Now of course, if your original code had been
    >
    > #include <stdio.h>
    > int main() { /* main starts here */
    > /* write code here */int i;
    > }
    >
    > Then once stripped, you would have had
    >
    > #include <stdio.h>
    > int main() {
    > int i;
    > }
    >
    > and should have expected 4 lines.



    Yes thats what it sounds like but my leader never believes that. Any
    ways or inconsistencies that you people can sight and tell me ?

    Thx
    ravi uday
    Ravi Uday, Jul 28, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Heavey
    Replies:
    1
    Views:
    363
    Oisín Grehan
    Dec 2, 2003
  2. =?Utf-8?B?YWRvbGYgZ2FybGlj?=

    BUG: commented out server side controls in html still run

    =?Utf-8?B?YWRvbGYgZ2FybGlj?=, Nov 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    416
    John Saunders
    Nov 22, 2004
  3. Rod Snyder

    commented out form tag causing error

    Rod Snyder, Sep 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    348
    Rod Snyder
    Sep 14, 2005
  4. bronski
    Replies:
    0
    Views:
    436
    bronski
    Feb 16, 2005
  5. John Salerno

    an error in commented code?

    John Salerno, Apr 28, 2006, in forum: Python
    Replies:
    4
    Views:
    335
    John Salerno
    Apr 28, 2006
Loading...

Share This Page