How to log the length of a struct array in string or integer?

Hello! I want log the struct array size.

TArray<FMyStruct> Arr{};
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, FString::Printf(TEXT("Struct Size: %s"), *UStruct::GetValueAsString(Arr)));

how to do it correctly?
Thank you :slight_smile:

int32 arrsize = sizeof(Arr);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, FString::Printf(TEXT("Struct Size: %d"), arrsize));

hope it helps
cheers

1 Like
TArray<FString> myarray;
GEngine->AddOnScreenDebugMessage(-1, 4.0f, FColor::White, FString::Printf(TEXT("Struct Size: %d"), myarray.Num()));

I had scrumbled up things before

1 Like

my array is struct type

yes it logs as int the size of my struct array but how to do it in string if it is possible?

I already showed the string in my code. And it does not matter, which contents the array has, I just used FString, could also be anything else)

So:

TArray<FMyStruct> myarray;
GEngine->AddOnScreenDebugMessage(-1, 4.0f, FColor::White, FString::Printf(TEXT("Struct Size: %d"), myarray.Num()));

And pure length number as string

GEngine->AddOnScreenDebugMessage(-1, 4.0f, FColor::White, FString::FromInt(myarray.Num()));

Added corrections, had just bad examples beforeโ€ฆ

1 Like

this is not the size of the array

this is size in strings and you already have the size in int32 to be logged in numbers

hope it helps
cheers!

1 Like

thank you very much for the perfect solutions :slight_smile: