fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void start();
  5. int humanTurn(int humanTotalScore);
  6. int computerTurn(int computerTotalScore);
  7. int numberTest = 5;
  8. int humanTotalScore = 0;
  9. char rollDecision;
  10.  
  11.  
  12.  
  13. int main()
  14. {
  15. start();
  16. humanTurn(numberTest);
  17.  
  18.  
  19. return 0;
  20.  
  21.  
  22.  
  23. }
  24.  
  25.  
  26. void start()
  27. {
  28. cout << "Welcome to the game of Pig!\n"
  29. << "This game is a simple two player dice game.\n"
  30. << "The first person to 100 points wins\n"
  31. << "On a players turn, they begin by rolling a dice\n"
  32. << "-If a player rolls a 2-6 they may:\n"
  33. << "Roll again\n"
  34. << "Hold\n"
  35. << "If a player holds, their points are added to their total\n"
  36. << "And the next player's turn begins\n"
  37. << "-If a player rolls a 1, they lose their turn\n"
  38. << "And the next player's turn begins\n\n"
  39. << "Player 1 rolls first.\n";
  40.  
  41. }
  42.  
  43. int humanTurn(int humanTotalScore)
  44. {
  45. cout << "Player 1 rolls "<< numberTest;
  46. cout << "Your total score is: " << humanTotalScore;
  47. cout <<"Do you want to roll again?('r' to roll again, 'h' to hold.)";
  48. cin >> rollDecision;
  49.  
  50. if (rollDecision == "r")
  51. {
  52. cout << "You roll again.\n"
  53. }
  54.  
  55. else if (rollDecision == "h")
  56. {
  57. cout << "You decide to hold.\n"
  58. }
  59. return numberTest;
  60. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int humanTurn(int)’:
prog.cpp:50:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  if (rollDecision == "r")
                      ^~~
prog.cpp:53:2: error: expected ‘;’ before ‘}’ token
  }
  ^
prog.cpp:55:27: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  else if (rollDecision == "h")
                           ^~~
prog.cpp:58:2: error: expected ‘;’ before ‘}’ token
  }
  ^
stdout
Standard output is empty