How to write data to a .txt file by c++?

I apologize if my question is too stupid,okay.As what I said,I created a pawn in UE4,I want to output its position every frame.I tried to use FFileHepler::SaveStringtoFile().But it only save the position in the last frame?How gotta i solve it?

WriteFlags = 8

As I know, there’s a virtual function named Tick, it will execute erery frame.

If you write your logic in it, it may work.

But if you put a I/O operation in Tick function, your application will not have a good performance.

Thank you for your answer,It works

emmmm,I tried to do like you said,My function is in the Tick().It only save the position of the last frame,the previous data will be covered.

I’m glad to hear that you’ve solve your problem. I found some info in FileManager.h

enum EFileWrite
{
	FILEWRITE_None				= 0x00,
	FILEWRITE_NoFail            = 0x01,
	FILEWRITE_NoReplaceExisting = 0x02,
	FILEWRITE_EvenIfReadOnly    = 0x04,
	FILEWRITE_Append			= 0x08,
	FILEWRITE_AllowRead			= 0x10,
	FILEWRITE_Silent			= 0x20
};

It maybe the reason of why “code 8” is the right way.