First Program - would like improvement suggestions

This is a discussion on First Program - would like improvement suggestions within the C++ Programming forums, part of the General Programming Boards category; I'm not sure where to post this, but figured this would be the best place. If it isn't or I'm ...

  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.
    Attached Files Attached Files

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,592
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 06:49 PM
  2. Inserting text into MDI program
    By Rutabega in forum Windows Programming
    Replies: 0
    Last Post: 12-23-2005, 10:25 AM
  3. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 04:23 PM
  4. Replies: 2
    Last Post: 05-10-2002, 04:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21