LINUXGAMES

LGP Development Project Submission: code counter

February 27th, 2003 by Alkini

We typically don’t attempt to cover Linux game development here, but Matt from mattsscripts.co.uk wrote in to share the code that he’s submitting for the LGP from-scratch project, which he calls “code counter.” What makes this interesting is that the code is designed to help other people who plan to also make submissions by making sure that their code also fits within the 2048 character limit that LGP specified.

4 Responses to “LGP Development Project Submission: code counter”

  1. bdove Says:

    Sumption that the line is no more than 1024 chars long..

    Rule #1, make no sumptions
    (atleast any that you cannot check on the fly)

    Why not use “>>” and read the hole thing into string for parsing. You cannot count the \r \f anyway as a chars.

    But nice pease of code anyway .. =D

  2. reborn Says:

    Heh, actually this wasn’t my submission to the “from-scratch project” application system, it was just something to help myself out if I decided to enter :)

    Re: “>>” over getline – maybe I should have used that, but to be honest it’s been a while since I’ve worked with cin (also “>>”) and couldn’t remember the method calls to change cin’s behaviour :P

  3. Anonymous Says:

    I hate to say it, but this script appears to be buggy, unless I don’t understand the requirements correctly. I ran it on a random C file I had sitting around. Then I copied the C file to a separate file and removed all comments and indentation. The program should have given the same size for both files, but it told me that the file without comments was 500 bytes larger!

  4. Anonymous Says:

    why not just use wc -c?

Leave a Reply

You must be logged in to post a comment.