Hi, I’m fairly new to C++ and Unreal, But i do have experience in Unity and C#. I feel im fundamentally not understanding how array’s are passed to a method. I have an array of data coming from an UDP port. I have that working correctly but i need to parse thought the data and organize it. I have created this method to pull data from the array but can’t get it to return the data correctly after i have called the method. The first time it’s called it gives me the right data the second time i call it in a loop it gives me an array of the correct size but all the values of the array are 0.
.h file
TArray GetData(TArray data, int startIndex, int count);
.cpp method
TArray ADataClass::GetData(TArray data, int startIndex, int count) {
static TArray<uint8> temp;
temp.SetNum(count);
for (size_t i = startIndex; i < count; i++)
{
temp[i - startIndex] = data[i];
}
return temp;
}
This is how im calling the method the get the data.
hs.headerData = GetData(incomingData, 0, 18);
That works when i need to grab it once. When i go to use the imcoingdata array again it give me issue.
I hope this makes sense and somoene can help me out
thanks in advanced