Challenge solution "WORD_LENGTH"

Well I had a laugh onthis when I saw the solution.

my original solution was this

cout << “Can you guess the” << " " << WORD_LENGTH << " " << “letter isogram I’m thinking of?\n”;

But then I had a laugh, :slight_smile: By the way would this not be good ?

cout << “Can you guess the " << WORD_LENGTH << " letter isogram I’m thinking of?\n”;

Is this a bad practice? Or did you separate the statement in two lines to make it easier for your screen in the video?

Thanks

PS: In your video inthe .cpp you spelled WORLD_LENGTH and it should be WORD_LENGTH. :slight_smile:

I can’t say if this would be a good or bad practice, but I had mine all on one line as well. I also didn’t get the solution completely correct without going forward in the video. I had the right idea, but I was trying to insert too much into it. Like int WORD_LENGTH, or std:: <<WORD_LENGTH…

After a few minutes of frustration, I was glad to see that I had the right idea.

I know this answer is two years late but maybe someone reading this now might find it useful.

Your answer is essentially the same as the solution provided. The compiler will concatenate two strings that are separated by << into one in its implementation.

1 Like

I think Ben was just demonstrating the concept of whitespace, and the fact that unless you specify that you want things on a new line, C++ will just place the strings next to each other.

Privacy & Terms