Fun using structs

Im going through Section 2 again, i had already gone through the entire section a few months ago. This time i have a better understanding of c++.

While going through the videos up until now, i have been trying to keep my functions a clean and concise as possible, it is for this reason i have been passing paramaters into my functions. I should not have to re define anything in a function, so i moved my declarations into a struct for now. Later on in the course when we begin to use classes this will no longer be necessary, but for now it makes my code simple.

Check it out here and let me know your thoughts
My Code

I think its better if you just declare a function in the header, instead of putting the whole functions before the main. In main opinion, it will improve the understanding. F.e:

void printGame(int32 wordLength);
void playGame(Info data);

//application entry point
int main()
{
Info data;
printGame(data.isoLength);
playGame(data);
return 0;
}

void printGame(int32 wordLength)

//prints the guess back to the player
void printGuess(std::string guess)
{
std::cout << guess << std::endl << std::endl;
}

void playGame(Info data)
{
for (int32 currentTry = 0; currentTry < data.numberOfTries; currentTry++)
{
printGuess(getGuess(data.userGuess, data.isoLength));
}
}

Regards

You mean using the prototypes? i realized i could save space by moving my main() to the bottom, but your right, doing this sacrifices readability.

Eventually this will not matter as all these functions will be moved into another file. When this happens we wont really need the prototypes.

example here

Privacy & Terms