#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    28
    Rep Power
    0

    Showing Statements after User Input


    Hi everyone. I have a problem which is that I have a program that I need help showing a statement after the users input which is a button press.

    For example

    Code:
    cout << "Whats your issue? Press Enter for a solution"
    
    case 0;
    cout << "The Solution is A"
    break
    
    case 1;
    cout << "The Solution is B"
    break
    I need to output from the cases to show ONLY after the enter button was pressed. How can I make this happen?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,714
    Rep Power
    480
    Please, in which computer language is this code snippet intended?
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Please, in which computer language is this code snippet intended?
    That is pseudocode for C++
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,714
    Rep Power
    480
    cin >> pseudocode_for_an_answer
    Last edited by b49P23TIvg; February 18th, 2014 at 09:36 PM. Reason: oops, I meant cin. I was thinking sin. Honestly.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by b49P23TIvg
    cout >> pseudocode_for_an_answer
    I have don't that but the answer is displayed right away as opposed to waiting for the button press then coming on.
  10. #6
  11. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,091
    Rep Power
    2222
    Originally Posted by fxlightning06
    I have don't that but the answer is displayed right away as opposed to waiting for the button press then coming on.
    Certainly not with that pseudo-code!

    That you would describe the program's actions means that there must exist some actual code, which apparently contains something akin to cin.getchar(). Perhaps if you were to divulge that actual code we might be able to make some kind of progress.
    Last edited by dwise1_aol; February 18th, 2014 at 05:10 PM.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by dwise1_aol
    Certainly not with that pseudo-code!

    That you would describe the program's actions means that there must exist some actual code, which apparently contains something akin to cin.getchar(). Perhaps if you were to divulge that actual code we might be able to make some kind of progress.


    Code:
    	cout << "Go On, Think of A Question and Hit Enter" << endl;
    	  srand ((unsigned)time(0));
    	  int answer;
          answer = rand () % 2;
    
    	  switch(answer){
    
    		    case 0:
    			  cout << "Answer 1" <<endl;
    			  break;
    
    			case 1:
    			  cout << "Answer 2" <<endl;
    			  break; }
    The case shows right away and not after the button press as I intended.
  14. #8
  15. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,091
    Rep Power
    2222
    So add an input statement. How can you account for the user having pressed a button until you input that action?

    You eventually want the user to input an answer, so input an answer. You want to ignore that answer for now, so ignore it for now.

IMN logo majestic logo threadwatch logo seochat tools logo