loop problem

This is a discussion on loop problem within the C++ Programming forums, part of the General Programming Boards category; It allows you to run dice as often as you want, the problem is that after u roll dice and ...

  1. #16
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    It allows you to run dice as often as you want, the problem is that after u roll dice and try to go back to the main menu it does

    Enter command:
    Enter h for help:
    Enter command:

  2. #17
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    What main menu?

    You have a main function, which repeatedly calls commandmain() until it returns non zero. When it gets a non zero, it exits.

    In commandmain() you set commain to zero, all of the options return zero except quit which returns -1.

    Each of the options are effectively the same, you roll some dice and it gives you a value you have rolled.

    As I have said, twice now, and posted a picture of it, the program does just that, you can run the options until you enter quit, when it quits. Where is this main menu? Post a picture of it "not working", frankly I don't see what your problem is.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #18
    lurker
    Guest
    What I think 'noobie' is trying to say is, yes, it works in that you can keep rolling the dice until you type 'quit', but instead of just saying

    Code:
    Enter a command:dice
    Enter a number of 6-sided dice to roll:36
    
    You rolled for a total of 114!
    Enter a command:
    it says:
    Code:
    Enter a command:dice
    Enter a number of 6-sided dice to roll:36
    
    You rolled for a total of 114!
    Enter a command:
    Enter help for assistance:
    Enter a command:
    with the extraneous 'Enter help...Enter a command'. Noobie - I believe the problem is due to the fact that you call the function 'commandmain' in the 'while' condition, then you call it again as part of the while loop - as noted by orbitz. You may want to modify the 'while' condition.

  4. #19
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    If that is what he means, he has an odd way of phrasing his questions! He said it doesn't work after rolling the dice once, but it does. Now he is talking about a main menu, there isn't one!
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Addition problem in loop
    By murjax in forum C Programming
    Replies: 3
    Last Post: 07-01-2009, 06:29 PM
  2. validation problem in a loop (newbie question)
    By Aisthesis in forum C++ Programming
    Replies: 11
    Last Post: 05-10-2009, 10:47 PM
  3. For Loop Problem
    By xp5 in forum C Programming
    Replies: 10
    Last Post: 09-05-2007, 04:37 PM
  4. Loop problem
    By Tesnik in forum C++ Programming
    Replies: 29
    Last Post: 08-23-2007, 10:24 AM
  5. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM

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