Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would recommend following a nice tutorial like this <a href="http://www.cplusplus.com/doc/tutorial/program_structure/" rel="nofollow">tutorial on cplusplus.com</a>. This code will compile and run, but most probably it will not do what you expected it to do. For example,</p> <pre><code>while (running) { } </code></pre> <p>This code will never stop, because the variable running is never set to 0/false. It should be set to 0 in the loop it self. The following code is not very functional right now, but it compiles :)</p> <pre><code>#include&lt;iostream&gt; using namespace std; bool running = 1; void newGameFunc(); void titleFunc(); int userInput = 0; int playerInfo[2]; // player info, change variable to number of options for the player int main() { titleFunc(); // You call/execute the function titlefunc return 0; // and after that return from the main function // this ends your program/game } void titleFunc() { cout &lt;&lt; "\t\t\t\t game dialogue \n\n\n"; cout &lt;&lt; "game dialogue"; cin &gt;&gt; userInput; if (userInput == 1) { newGameFunc(); } else { running = 0; } return; // A void function does not return anything } void newGameFunc() { cout &lt;&lt; "game dialogue \n"; cout &lt;&lt; "game dialogue.\n"; cout &lt;&lt; "game dialogue"; cin &gt;&gt; userInput; playerInfo[0] = userInput; cout &lt;&lt; "game dialogue\n"; cin &gt;&gt; userInput; playerInfo[1] = userInput; while (running) { cin &gt;&gt; userInput; if(userInput==0) { running = 0; } // Other code that should be executed while the game loop is active } return; } </code></pre> <p>Good luck with your game!, and with your life as a programmer :)</p>
    singulars
    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