I have a C# code calling a C++ function.
The C++ function should fill a buffer passed with a pointer. However, the array returns empty.
The import declaration is:
[DllImport("ProjectLogicInterface", EntryPoint = "FillArr", CallingConvention = CallingConvention.Cdecl)]
public static extern UInt32 FillArr(char[] arr);
The code, after simplifications and entering some hard coded values looks like that:
The code in C#:
char[] arr= new char[10];
ret = LogicInterface.FillArr(arr);
The C++ code:
bool FillArr(char* arr)
{
int length=10;
for(int i = 0; i < length; i++)
{
arr[i] = 3; //replaced with some hard coded value
}
return true;
}
However, the array remains empty.
Any suggestions?