How to orient an actor towards another actor (without a movement component) in C++?

Not in my computer, but it could be something like this:

FVector direction = TargetLocation- GetActorLocation();
direction.Normalize();

auto lookat = FRotationMatrix::MakeFromX(direction).Rotator();
lookat.Pitch = 0.0f;
lookat.Roll = 0.0f;

SetActorRotation(lookat);

Where TargetLocation is as the name suggests, the location of the actor you want to look at. I set Pitch and Roll to zero, because I only wanted to turn

If I have two actors, is there a way to set its rotation to face the other actor in C++?

Thanks in advance

I believe there there is a FindLookAtRotation() in the math library already, but I like your example more.

That worked perfectly. Thank you!