If you are using Questa, you should always use the vlog -dpiheader switch to generate a header file
vlog -dpiheader dpiheader.h hello.sv hello.c
and then in your DPI C file
#include "dpiheader.h"
This ensures that your SV task/function prototypes match your C routine prototypes. You will get a compile time error if they don’t instead of a run time segmentation fault or some other weird behavior.
The header your example creates is
void ABC(
const svOpenArrayHandle str);
The you would use
void *svGetArrElemPtr1(const svOpenArrayHandle, int indx1);
Good. FYI, there is no need for the foreach statement in the code that you showed. You never iterate over i. You just make 20 assignments to d[0]. And there is no need to declare the foreach iterator variable i even if you do wind up using it.