Download

How get TArray<FString> value?

Hi;

I would like to print content of my array to log message. My array declaration is :



UPROPERTY(EditAnywhere, BlueprintReadWrite )
    TArray<FString> MyInventories;


Codes in My Pawn character class:



// By pressing "I" :
void APawnCharacter::ShowInventoriesList()
{
    for (int32 Index = 0; Index != MyInventories.Num(); ++Index)
    {
        UE_LOG(LogTemp, Warning, TEXT("Info= %s"), **MyInventories**[Index]);        
    }
}


My problem is on this line:
UE_LOG(LogTemp, Warning, TEXT(“Info= %s”), MyInventories[Index]);

and visual studio complaints :



1>  C:\Program Files (x86)\Epic Games\4.14\Engine\Source\Runtime\Core\Public\Logging\LogMacros.h(37): note: while trying to match the argument list '(FString)'
1>  D:\1_Game Production\0_Unreal Engine 4\UE4 Projects\SodaDrink\SodaDrink\Source\SodaDrink\PawnCharacter.cpp(93): note: see reference to function template instantiation 'void FMsg::Logf_Internal<FString>(const ANSICHAR *,int32,const FName &,ELogVerbosity::Type,const TCHAR *,T1)' being compiled
1>          with
1>          
1>              T1=FString
1>          ]
1>ERROR : UBT error : Failed to produce item: D:\1_Game Production\0_Unreal Engine 4\UE4 Projects\SodaDrink\SodaDrink\Binaries\Win64\UE4Editor-SodaDrink-8006.dll
1>  Total build time: 3.37 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3075: The command ""C:\Program Files (x86)\Epic Games\4.14\Engine\Build\BatchFiles\Build.bat" SodaDrinkEditor Win64 Development "D:\1_Game Production\0_Unreal Engine 4\UE4 Projects\SodaDrink\SodaDrink\SodaDrink.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Any Idea to help?

Thanks.
MSD.

Convert FString to tchar array, do this:



EU_LOG(LogTemp, Warning, TEXT("Info= %s"), *MyInventories[Index]);


Thank you BrUno, It works…