C++ Dot Operator

In this lesson, we cover using the C++ dot operator on an FString.

VSCode shows us functions we can call on the FString. From what you can see, what functions do you think will be handy for us in this section?

Maybe to gain access to the individual letters of the word.

I must have done something terribly wrong, as when I follow along with the lesson, I don’t get a dot operator dropdown after " if (Input." like in the video.

I can’t type anything into the terminal when I play the game.
It doesn’t seem to recognize my input. Instead the player still just moves around if I type w, a, s or d.

Edit: Sorry, I found it. I watched the tutorial again and I had somehow missed that we have to press tab to switch to the terminal.

1 Like

Looks like “Find” might be useful to find the Bulls and Cows.
Also the “Compare” will be a good one.

Im getting an error on line 19 for “else”

The error reads: “expected a statement [19, 5]”

My code:

// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"

void UBullCowCartridge::BeginPlay() // When the game starts
{
    Super::BeginPlay();
    PrintLine(TEXT("Welcome to Bulls and Cows!"));
    PrintLine(TEXT("Guess the four letter word..."));
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
    ClearScreen();
    FString HiddenWord = TEXT("Fire"); 
    if (Input.Len() == HiddenWord.Len());
    {
        PrintLine(TEXT("Correct amount of letters!"));
    }
    else
    {
        Printline(TEXT("Your word must be 4 letters!"));
    }

}

Solution: There was a “;” at the end of the “if” line, taking it out solved the issue.

I missed that too. Figured it out from your Edit.

Privacy & Terms