Thread: First Program - would like improvement suggestions

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    5

    First Program - would like improvement suggestions

    I'm not sure where to post this, but figured this would be the best place.
    If it isn't or I'm not supposed to make posts like this at all, please let me know so I can avoid it in future.

    Anyway, I finally finished my very first complete program that wasn't a tutorial.
    It's nothing big, just a simple dice generator that let's you choose between a d4 up to d100 and how often you want to roll, then writes the results to a file.

    Well, I'd like some critique on it, especially what could be done better or expanded.
    You don't need to go into detail, just a short mention is enough.
    I'll figure the rest out myself.

    I'll say thanks in advance for any help offered,

    V.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    With a couple of parameters, the body of every single case could be made into a single function.

    So you cases look like
    Code:
    case 1:
      doRolls( 4 );
      break;
    case 2:
      doRolls( 6 );
      break;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    5
    Sounds nice, I'll look into it.
    Thanks for the suggestion.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  2. Inserting text into MDI program
    By Rutabega in forum Windows Programming
    Replies: 0
    Last Post: 12-23-2005, 11:25 AM
  3. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM
  4. Replies: 2
    Last Post: 05-10-2002, 04:16 PM