What the main() function does according to me

Firstly it initiates the difficulty to be set to 2 and sets the maximum limit of difficulty to be 10.
While the difficulty is less then the maximum difficulty, it starts the PlayGameAtDifficulty function with the difficulty as a parameter.
Not sure exactly what std::cin does, but I think it resets the game after each round in order to increase the difficulty, therefore the ++difficulty line.

The last two lines of the code only happend if the condition for the while loop is not met, meaning the player has reached level 10 and it writes to the screen a message to the player.

I am pretty sure that return 0 means that it returns to line 0, meaning the code starts over from the beginning.

1 Like

The return statement returns a value from a function. From main(), returning an int indicates whether or not the application was successful in its purpose and 0 is success.

std::cin is a stream for console input - that is, reading key presses/user input from the console.

main itself is the first function to be executed in any C++ application and so it typically controls the application or rather what it does. In Unreal this will be hidden but it does exist somewhere.

I hope this helps. Welcome to the course.

Privacy & Terms