How to use C++ to transform bones of a skeleton?

Now I have a skeletal mesh, which is a face mesh with bones.
How can I animate this face with C++ by transforming bones of the skeleton?

You can do this by using a PoseableMeshComponent instead of a SkeletalMeshComponent. They’re similar, but the difference is that PoseableMeshComponent cannot use animations and expects to be manupilated on the game thread.

You cannot change bone transforms on the game thread in C++. There are several copies of the transforms used by different threads, and these must be carefully updated and synchronised.

This must be done using animation, usually via an animation blueprint. You can create animation classes by subclassing UAnimInstance, and there you can apply bone transform changes on the animation thread update functions. However, it is generally better practice to make anim BP’s.