Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue compiling program in CodeBlocks
    primarykey
    data
    text
    <p>I have successfully compiled/ran other programs but when I try to compile/run the code below, it tells me: "This project has not been built yet, do you want to build it now?". </p> <p>When I take int b out of the function getWinnings() it will compile/run, though if I add more arguments code::blocks gives me the message above. What is causing this?</p> <pre><code> #include &lt;iostream&gt; #include &lt;ctime&gt; #include &lt;cstdlib&gt; #include &lt;string&gt; int gameCoins; using namespace std; void instructions(); void playSlots(); void spin(); int main() { srand(time(NULL)); instructions(); playSlots(); } void instructions() { cout &lt;&lt; "\t\t" &lt;&lt; "VIRTUAL SLOT MACHINE" &lt;&lt; "\n\n"; cout &lt;&lt; "INSTRUCTIONS: " &lt;&lt; endl &lt;&lt; "You start with 500 coins. The game is over either when you run out of coins or you quit the game." &lt;&lt; "\n"; cout &lt;&lt; "It will cost you 25 coins per spin. Good luck!" &lt;&lt; "\n\n" ; } void playSlots() { string user_input; string replay_or_quit; while (replay_or_quit != "n" &amp;&amp; replay_or_quit != "no") { gameCoins = 500; cout &lt;&lt; "Coins: " &lt;&lt; gameCoins &lt;&lt; "\n"; while (user_input != "spin" &amp;&amp; user_input != "Spin") { cout &lt;&lt; "Spin the wheels to start playing. Type 'spin' to begin" &lt;&lt; "\n"; cin &gt;&gt; user_input; cout &lt;&lt; "\n\n"; } spin(); while (gameCoins &gt; 0 &amp;&amp; user_input != "no" &amp;&amp; user_input != "n") { cout &lt;&lt; "Spin again?" &lt;&lt; "\n" &lt;&lt; "Decision: "; cin &gt;&gt; user_input; if (user_input == "y" || user_input == "yes") spin(); } if (gameCoins == 0) { cout &lt;&lt; "You went broke. Play again?" &lt;&lt; "\n" &lt;&lt; "Decision: "; cin &gt;&gt; replay_or_quit; } else { cout &lt;&lt; "Congratulations, you won " &lt;&lt; gameCoins &lt;&lt; " coins. Play again?" &lt;&lt; "\n" &lt;&lt; "Decision: "; cin &gt;&gt; replay_or_quit; } } } int getWinnings(int a, int b) { return (a+b); } void spin() { int wheelOne_Top, wheelOne_Mid, wheelOne_Bot; int wheelTwo_Top, wheelTwo_Mid, wheelTwo_Bot; int wheelThree_Top, wheelThree_Mid, wheelThree_Bot; int coinsWon; gameCoins = gameCoins-25; wheelOne_Top = (rand() % 3) + 1, wheelTwo_Top = (rand() % 3) + 1, wheelThree_Top = (rand() % 3) + 1; wheelOne_Mid = (rand() % 3) + 1, wheelTwo_Mid = (rand() % 3) + 1, wheelThree_Mid = (rand() % 3) + 1; wheelOne_Bot = (rand() % 3) + 1, wheelTwo_Bot = (rand() % 3) + 1, wheelThree_Bot = (rand() % 3) + 1; while (wheelOne_Top == wheelOne_Mid || wheelOne_Top == wheelOne_Bot || wheelOne_Bot == wheelOne_Mid) { wheelOne_Mid = (rand() % 3) + 1; wheelOne_Bot = (rand() % 3) + 1; } while (wheelTwo_Top == wheelTwo_Mid || wheelTwo_Top == wheelTwo_Bot || wheelTwo_Bot == wheelTwo_Mid) { wheelTwo_Mid = (rand() % 3) + 1; wheelTwo_Bot = (rand() % 3) + 1; } while (wheelThree_Top == wheelThree_Mid || wheelThree_Top == wheelThree_Bot || wheelThree_Bot == wheelThree_Mid) { wheelThree_Mid = (rand() % 3) + 1; wheelThree_Bot = (rand() % 3) + 1; } cout &lt;&lt; "Coins: " &lt;&lt; gameCoins &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; "\t\t\t" &lt;&lt; wheelOne_Top &lt;&lt; " " &lt;&lt; wheelTwo_Top &lt;&lt; " " &lt;&lt; wheelThree_Top &lt;&lt; "\n"; cout &lt;&lt; "\t\t\t" &lt;&lt; wheelOne_Mid &lt;&lt; " " &lt;&lt; wheelTwo_Mid &lt;&lt; " " &lt;&lt; wheelThree_Mid &lt;&lt; "\n"; cout &lt;&lt; "\t\t\t" &lt;&lt; wheelOne_Bot &lt;&lt; " " &lt;&lt; wheelTwo_Bot &lt;&lt; " " &lt;&lt; wheelThree_Bot &lt;&lt; "\n\n"; coinsWon = getWinnings(wheelOne_Top, wheelOne_Mid); gameCoins = coinsWon + gameCoins; if (gameCoins &gt; 0) cout &lt;&lt; "You won " &lt;&lt; gameCoins &lt;&lt; " coins!" &lt;&lt; "\n" &lt;&lt; "Total Coins: " &lt;&lt; gameCoins &lt;&lt; "\n\n"; else cout &lt;&lt; "You lost 25 coins!" &lt;&lt; "\n" &lt;&lt; "Total coins: " &lt;&lt; gameCoins &lt;&lt; "\n\n"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload