HiveBrain v1.2.0
Get Started
← Back to all entries
patterncppMinor

Char string review

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
charreviewstring

Problem

#include "stdafx.h"
#include 

using namespace std;

int main ()
{
    for (int i = 0; i >guess;

        if (guess == "Dog")
        {
            cout >f;
    return 0;
}

Solution

#include "stdafx.h" is superfluous.

The standard idiom in C++ for doing something 4 times is:

for (int i = 0; i < 4; i++) {
    ...
}


Don't deviate from that pattern unless there is a good reason.

Requiring an extra character input to exit the program is a weird user experience, especially since there is no prompt. I would just get rid of char f; cin >> f;.

Code Snippets

for (int i = 0; i < 4; i++) {
    ...
}

Context

StackExchange Code Review Q#38396, answer score: 5

Revisions (0)

No revisions yet.